Mercurial > vim
annotate src/testdir/test_listdict.vim @ 29263:8408ffd9af69 v8.2.5150
patch 8.2.5150: read past the end of the first line with ":0;'{"
Commit: https://github.com/vim/vim/commit/f7c7c3fad6d2135d558f3b36d0d1a943118aeb5e
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 22 19:08:38 2022 +0100
patch 8.2.5150: read past the end of the first line with ":0;'{"
Problem: Read past the end of the first line with ":0;'{".
Solution: When on line zero check the column is valid for line one.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 22 Jun 2022 20:15:03 +0200 |
parents | 35e24d9de858 |
children | bdb31515f78b |
rev | line source |
---|---|
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for the List and Dict types |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
2 scriptencoding utf-8 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
4 import './vim9.vim' as v9 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
5 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 func TearDown() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " Run garbage collection after every test |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 call test_garbagecollect_now() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 " Tests for List type |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 " List creation |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 func Test_list_create() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 " Creating List directly with different types |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call assert_equal("[1, 'as''d', [1, 2, function('strlen')], {'a': 1}]", string(l)) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 call assert_equal({'a' : 1}, l[-1]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call assert_equal(1, l[-4]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 let x = 10 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 let x = l[-5] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 call assert_match('E684:', v:exception) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal(10, x) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 |
21556
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
29 " This was allowed in legacy Vim script |
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
30 let s:list_with_spaces = [1 , 2 , 3] |
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
31 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 " List slices |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 func Test_list_slice() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 let l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[:]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call assert_equal(['as''d', [1, 2, function('strlen')], {'a': 1}], l[1:]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 call assert_equal([1, 'as''d', [1, 2, function('strlen')]], l[:-2]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 call assert_equal([1, 'as''d', [1, 2, function('strlen')], {'a': 1}], l[0:8]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 call assert_equal([], l[8:-1]) |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
40 call assert_equal([], l[0:-10]) |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
41 " perform an operation on a list slice |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
42 let l = [1, 2, 3] |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
43 let l[:1] += [1, 2] |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
44 let l[2:] -= [1] |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
45 call assert_equal([2, 4, 2], l) |
25599
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
46 |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
47 let lines =<< trim END |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
48 VAR l = [1, 2] |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
49 call assert_equal([1, 2], l[:]) |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
50 call assert_equal([2], l[-1 : -1]) |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
51 call assert_equal([1, 2], l[-2 : -1]) |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
52 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
53 call v9.CheckLegacyAndVim9Success(lines) |
25599
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
54 |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
55 let l = [1, 2] |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
56 call assert_equal([], l[-3 : -1]) |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
57 |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
58 let lines =<< trim END |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
59 var l = [1, 2] |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
60 assert_equal([1, 2], l[-3 : -1]) |
b85e44974a08
patch 8.2.3336: behavior of negative index in list change changed
Bram Moolenaar <Bram@vim.org>
parents:
25597
diff
changeset
|
61 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
62 call v9.CheckDefAndScriptSuccess(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 " List identity |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 func Test_list_identity() |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
67 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
68 VAR l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
69 VAR ll = l |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
70 VAR lx = copy(l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
71 call assert_true(l == ll) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
72 call assert_false(l isnot ll) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
73 call assert_true(l is ll) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
74 call assert_true(l == lx) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
75 call assert_false(l is lx) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
76 call assert_true(l isnot lx) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
77 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
78 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 " removing items with :unlet |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 func Test_list_unlet() |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
83 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
84 VAR l = [1, 'as''d', [1, 2, function("strlen")], {'a': 1},] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
85 unlet l[2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
86 call assert_equal([1, 'as''d', {'a': 1}], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
87 LET l = range(8) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
88 unlet l[: 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
89 unlet l[1 :] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
90 call assert_equal([4], l) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
92 #" removing items out of range: silently skip items that don't exist |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
93 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
94 unlet l[2 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
95 call assert_equal([0, 1, 3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
96 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
97 unlet l[2 : 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
98 call assert_equal([0, 1], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
99 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
100 unlet l[2 : 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
101 call assert_equal([0, 1], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
102 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
103 unlet l[2 : 5] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
104 call assert_equal([0, 1], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
105 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
106 unlet l[-2 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
107 call assert_equal([0, 1, 3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
108 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
109 unlet l[-3 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
110 call assert_equal([0, 3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
111 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
112 unlet l[-4 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
113 call assert_equal([3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
114 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
115 unlet l[-5 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
116 call assert_equal([3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
117 LET l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
118 unlet l[-6 : 2] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
119 call assert_equal([3], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
120 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
121 call v9.CheckLegacyAndVim9Success(lines) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
122 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
123 let l = [0, 1, 2, 3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
124 unlet l[2:2] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
125 call assert_equal([0, 1, 3], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
126 let l = [0, 1, 2, 3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
127 unlet l[2:3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
128 call assert_equal([0, 1], l) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
129 |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
130 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
131 VAR l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
132 unlet l[2 : 1] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
133 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
134 call v9.CheckLegacyAndVim9Failure(lines, 'E684:') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
135 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
136 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
137 VAR l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
138 unlet l[-1 : 2] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
139 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
140 call v9.CheckLegacyAndVim9Failure(lines, 'E684:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
141 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
142 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
143 " assignment to a list |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
144 func Test_list_assign() |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
145 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
146 VAR l = [0, 1, 2, 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
147 VAR va = 0 |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
148 VAR vb = 0 |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
149 LET [va, vb] = l[2 : 3] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
150 call assert_equal([2, 3], [va, vb]) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
151 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
152 call v9.CheckLegacyAndVim9Success(lines) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
153 |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
154 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
155 let l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
156 let [va, vb] = l |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
157 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
158 call v9.CheckScriptFailure(lines, 'E687:') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
159 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
160 var l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
161 var va = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
162 var vb = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
163 [va, vb] = l |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
164 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
165 call v9.CheckScriptFailure(['vim9script'] + lines, 'E687:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
166 call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 4') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
167 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
168 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
169 let l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
170 let [va, vb] = l[1:1] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
171 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
172 call v9.CheckScriptFailure(lines, 'E688:') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
173 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
174 var l = [0, 1, 2, 3] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
175 var va = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
176 var vb = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
177 [va, vb] = l[1 : 1] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
178 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
179 call v9.CheckScriptFailure(['vim9script'] + lines, 'E688:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
180 call v9.CheckDefExecFailure(lines, 'E1093: Expected 2 items but got 1') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
181 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
182 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
183 " test for range assign |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
184 func Test_list_range_assign() |
25591
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
185 let lines =<< trim END |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
186 VAR l = [0] |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
187 LET l[:] = [1, 2] |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
188 call assert_equal([1, 2], l) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
189 LET l[-4 : -1] = [5, 6] |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
190 call assert_equal([5, 6], l) |
ea69398b40d1
patch 8.2.3332: Vim9: cannot assign to range in list
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
191 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
192 call v9.CheckLegacyAndVim9Success(lines) |
25603
525ef4d1d412
patch 8.2.3338: Vim9: no type check when assigning a list range
Bram Moolenaar <Bram@vim.org>
parents:
25599
diff
changeset
|
193 |
525ef4d1d412
patch 8.2.3338: Vim9: no type check when assigning a list range
Bram Moolenaar <Bram@vim.org>
parents:
25599
diff
changeset
|
194 let lines =<< trim END |
525ef4d1d412
patch 8.2.3338: Vim9: no type check when assigning a list range
Bram Moolenaar <Bram@vim.org>
parents:
25599
diff
changeset
|
195 var l = [7] |
525ef4d1d412
patch 8.2.3338: Vim9: no type check when assigning a list range
Bram Moolenaar <Bram@vim.org>
parents:
25599
diff
changeset
|
196 l[:] = ['text'] |
525ef4d1d412
patch 8.2.3338: Vim9: no type check when assigning a list range
Bram Moolenaar <Bram@vim.org>
parents:
25599
diff
changeset
|
197 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
198 call v9.CheckDefAndScriptFailure(lines, 'E1012:', 2) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
199 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
200 |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
201 " Test removing items in list |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
202 func Test_list_func_remove() |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
203 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
204 #" Test removing 1 element |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
205 VAR l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
206 call assert_equal(1, remove(l, 0)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
207 call assert_equal([2, 3, 4], l) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
208 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
209 LET l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
210 call assert_equal(2, remove(l, 1)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
211 call assert_equal([1, 3, 4], l) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
212 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
213 LET l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
214 call assert_equal(4, remove(l, -1)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
215 call assert_equal([1, 2, 3], l) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
216 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
217 #" Test removing range of element(s) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
218 LET l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
219 call assert_equal([3], remove(l, 2, 2)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
220 call assert_equal([1, 2, 4], l) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
221 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
222 LET l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
223 call assert_equal([2, 3], remove(l, 1, 2)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
224 call assert_equal([1, 4], l) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
225 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
226 LET l = [1, 2, 3, 4] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
227 call assert_equal([2, 3], remove(l, -3, -2)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
228 call assert_equal([1, 4], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
229 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
230 call v9.CheckLegacyAndVim9Success(lines) |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
231 |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
232 " Test invalid cases |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
233 let l = [1, 2, 3, 4] |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
234 call assert_fails("call remove(l, 5)", 'E684:') |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
235 call assert_fails("call remove(l, 1, 5)", 'E684:') |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
236 call assert_fails("call remove(l, 3, 2)", 'E16:') |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
237 call assert_fails("call remove(1, 0)", 'E896:') |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
238 call assert_fails("call remove(l, l)", 'E745:') |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
239 endfunc |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
240 |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
241 " List add() function |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
242 func Test_list_add() |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
243 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
244 VAR l = [] |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
245 call add(l, 1) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
246 call add(l, [2, 3]) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
247 call add(l, []) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
248 call add(l, test_null_list()) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
249 call add(l, {'k': 3}) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
250 call add(l, {}) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
251 call add(l, test_null_dict()) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
252 call assert_equal([1, [2, 3], [], [], {'k': 3}, {}, {}], l) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
253 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
254 call v9.CheckLegacyAndVim9Success(lines) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
255 |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
256 " weird legacy behavior |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
257 call assert_equal(1, add(test_null_list(), 4)) |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
258 endfunc |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
259 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
260 " Tests for Dictionary type |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
261 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
262 func Test_dict() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
263 " Creating Dictionary directly with different types |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
264 let lines =<< trim END |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
265 VAR d = {'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}, } |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
266 call assert_equal("{'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}", string(d)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
267 call assert_equal('asd', d.1) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
268 call assert_equal(['-1', '1', 'b'], sort(keys(d))) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
269 call assert_equal(['asd', [1, 2, function('strlen')], {'a': 1}], values(d)) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
270 call extend(d, {3: 33, 1: 99}) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
271 call extend(d, {'b': 'bbb', 'c': 'ccc'}, "keep") |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
272 call assert_equal({'c': 'ccc', '1': 99, 'b': [1, 2, function('strlen')], '3': 33, '-1': {'a': 1}}, d) |
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
273 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
274 call v9.CheckLegacyAndVim9Success(lines) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
275 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
276 let d = {001: 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1},} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
277 call assert_equal("{'1': 'asd', 'b': [1, 2, function('strlen')], '-1': {'a': 1}}", string(d)) |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
278 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
279 let v = [] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
280 for [key, val] in items(d) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
281 call extend(v, [key, val]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
282 unlet key val |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
283 endfor |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
284 call assert_equal(['1','asd','b',[1, 2, function('strlen')],'-1',{'a': 1}], v) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
285 |
25308
a386f83499ed
patch 8.2.3191: Vim9: not enough code is tested
Bram Moolenaar <Bram@vim.org>
parents:
25036
diff
changeset
|
286 call extend(d, {3: 33, 1: 99}) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
287 call assert_fails("call extend(d, {3:333,4:444}, 'error')", 'E737:') |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
288 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
289 " duplicate key |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
290 call assert_fails("let d = {'k' : 10, 'k' : 20}", 'E721:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
291 " missing comma |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
292 call assert_fails("let d = {'k' : 10 'k' : 20}", 'E722:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
293 " missing curly brace |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
294 call assert_fails("let d = {'k' : 10,", 'E723:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
295 " invalid key |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
296 call assert_fails('let d = #{++ : 10}', 'E15:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
297 " wrong type for key |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
298 call assert_fails('let d={[] : 10}', 'E730:') |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
299 " undefined variable as value |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
300 call assert_fails("let d={'k' : i}", 'E121:') |
26342
936f77929f16
patch 8.2.3702: first key in dict is seen as curly expression and fails
Bram Moolenaar <Bram@vim.org>
parents:
26329
diff
changeset
|
301 |
936f77929f16
patch 8.2.3702: first key in dict is seen as curly expression and fails
Bram Moolenaar <Bram@vim.org>
parents:
26329
diff
changeset
|
302 " allow key starting with number at the start, not a curly expression |
936f77929f16
patch 8.2.3702: first key in dict is seen as curly expression and fails
Bram Moolenaar <Bram@vim.org>
parents:
26329
diff
changeset
|
303 call assert_equal({'1foo': 77}, #{1foo: 77}) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
304 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
305 |
21556
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
306 " This was allowed in legacy Vim script |
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
307 let s:dict_with_spaces = {'one' : 1 , 'two' : 2 , 'three' : 3} |
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
308 let s:dict_with_spaces_lit = #{one : 1 , two : 2 , three : 3} |
963913d80284
patch 8.2.1328: no space allowed before comma in list
Bram Moolenaar <Bram@vim.org>
parents:
21512
diff
changeset
|
309 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
310 " Dictionary identity |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
311 func Test_dict_identity() |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
312 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
313 VAR d = {'1': 'asd', 'b': [1, 2, function('strlen')], -1: {'a': 1}, } |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
314 VAR dd = d |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
315 VAR dx = copy(d) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
316 call assert_true(d == dd) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
317 call assert_false(d isnot dd) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
318 call assert_true(d is dd) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
319 call assert_true(d == dx) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
320 call assert_false(d is dx) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
321 call assert_true(d isnot dx) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
322 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
323 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
324 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
325 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
326 " removing items with :unlet |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
327 func Test_dict_unlet() |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
328 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
329 VAR d = {'b': 'bbb', '1': 99, '3': 33, '-1': {'a': 1}} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
330 unlet d.b |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
331 unlet d[-1] |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
332 call assert_equal({'1': 99, '3': 33}, d) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
333 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
334 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
335 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
336 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
337 " manipulating a big Dictionary (hashtable.c has a border of 1000 entries) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
338 func Test_dict_big() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
339 let d = {} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
340 for i in range(1500) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
341 let d[i] = 3000 - i |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
342 endfor |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
343 call assert_equal([3000, 2900, 2001, 1600, 1501], [d[0], d[100], d[999], d[1400], d[1499]]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
344 let str = '' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
345 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
346 let n = d[1500] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
347 catch |
22754
837756417c5e
patch 8.2.1925: list/dict test fails
Bram Moolenaar <Bram@vim.org>
parents:
22547
diff
changeset
|
348 let str = substitute(v:exception, '\v(.{14}).*( "\d{4}").*', '\1\2', '') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
349 endtry |
22754
837756417c5e
patch 8.2.1925: list/dict test fails
Bram Moolenaar <Bram@vim.org>
parents:
22547
diff
changeset
|
350 call assert_equal('Vim(let):E716: "1500"', str) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
351 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
352 " lookup each items |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
353 for i in range(1500) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
354 call assert_equal(3000 - i, d[i]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
355 endfor |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
356 let i += 1 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
357 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
358 " delete even items |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
359 while i >= 2 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
360 let i -= 2 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
361 unlet d[i] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
362 endwhile |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
363 call assert_equal('NONE', get(d, 1500 - 100, 'NONE')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
364 call assert_equal(2999, d[1]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
365 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
366 " delete odd items, checking value, one intentionally wrong |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
367 let d[33] = 999 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
368 let i = 1 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
369 while i < 1500 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
370 if i != 33 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
371 call assert_equal(3000 - i, d[i]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
372 else |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
373 call assert_equal(999, d[i]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
374 endif |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
375 unlet d[i] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
376 let i += 2 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
377 endwhile |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
378 call assert_equal({}, d) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
379 unlet d |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
380 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
381 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
382 " Dictionary function |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
383 func Test_dict_func() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
384 let d = {} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
385 func d.func(a) dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
386 return a:a . len(self.data) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
387 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
388 let d.data = [1,2,3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
389 call assert_equal('len: 3', d.func('len: ')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
390 let x = d.func('again: ') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
391 call assert_equal('again: 3', x) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
392 let Fn = d.func |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
393 call assert_equal('xxx3', Fn('xxx')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
394 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
395 |
21512
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
396 func Test_dict_assign() |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
397 let d = {} |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
398 let d.1 = 1 |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
399 let d._ = 2 |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
400 call assert_equal({'1': 1, '_': 2}, d) |
25036
3b8d3b383fd6
patch 8.2.3055: strange error for assigning to "x.key" on non-dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24822
diff
changeset
|
401 |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
402 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
403 VAR d = {} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
404 LET d.a = 1 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
405 LET d._ = 2 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
406 call assert_equal({'a': 1, '_': 2}, d) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
407 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
408 call v9.CheckLegacyAndVim9Success(lines) |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
409 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
410 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
411 let n = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
412 let n.key = 3 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
413 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
414 call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
415 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
416 vim9script |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
417 var n = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
418 n.key = 3 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
419 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
420 call v9.CheckScriptFailure(lines, 'E1203: Dot can only be used on a dictionary: n.key = 3') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
421 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
422 var n = 0 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
423 n.key = 3 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
424 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
425 call v9.CheckDefFailure(lines, 'E1141:') |
21512
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
426 endfunc |
81c47a694479
patch 8.2.1306: checking for first character of dict key is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
427 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
428 " Function in script-local List or Dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
429 func Test_script_local_dict_func() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
430 let g:dict = {} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
431 function g:dict.func() dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
432 return 'g:dict.func' . self.foo[1] . self.foo[0]('asdf') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
433 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
434 let g:dict.foo = ['-', 2, 3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
435 call insert(g:dict.foo, function('strlen')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
436 call assert_equal('g:dict.func-4', g:dict.func()) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
437 unlet g:dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
438 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
439 |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
440 " Test removing items in a dictionary |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
441 func Test_dict_func_remove() |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
442 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
443 VAR d = {1: 'a', 2: 'b', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
444 call assert_equal('b', remove(d, 2)) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
445 call assert_equal({1: 'a', 3: 'c'}, d) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
446 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
447 call v9.CheckLegacyAndVim9Success(lines) |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
448 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
449 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
450 VAR d = {1: 'a', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
451 call remove(d, 1, 2) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
452 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
453 call v9.CheckLegacyAndVim9Failure(lines, 'E118:') |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
454 |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
455 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
456 VAR d = {1: 'a', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
457 call remove(d, 'a') |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
458 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
459 call v9.CheckLegacyAndVim9Failure(lines, 'E716:') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
460 |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
461 let lines =<< trim END |
26329
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
462 let d = {'a-b': 55} |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
463 echo d.a-b |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
464 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
465 call v9.CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') |
26329
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
466 |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
467 let lines =<< trim END |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
468 vim9script |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
469 var d = {'a-b': 55} |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
470 echo d.a-b |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
471 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
472 call v9.CheckScriptFailure(lines, 'E716: Key not present in Dictionary: "a"') |
26329
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
473 |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
474 let lines =<< trim END |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
475 var d = {'a-b': 55} |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
476 echo d.a-b |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
477 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
478 call v9.CheckDefFailure(lines, 'E1004: White space required before and after ''-''') |
26329
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
479 |
8afd7aa25ab6
patch 8.2.3695: confusing error for missing key
Bram Moolenaar <Bram@vim.org>
parents:
25603
diff
changeset
|
480 let lines =<< trim END |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
481 let d = {1: 'a', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
482 call remove(d, []) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
483 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
484 call v9.CheckScriptFailure(lines, 'E730:') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
485 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
486 vim9script |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
487 var d = {1: 'a', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
488 call remove(d, []) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
489 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
490 call v9.CheckScriptFailure(lines, 'E1220: String or Number required for argument 2') |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
491 let lines =<< trim END |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
492 var d = {1: 'a', 3: 'c'} |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
493 call remove(d, []) |
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
494 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
495 call v9.CheckDefExecFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got list<unknown>') |
14856
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
496 endfunc |
c5a2fb8b221d
patch 8.1.0440: remove() with a range not sufficiently tested
Christian Brabandt <cb@256bit.org>
parents:
12788
diff
changeset
|
497 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
498 " Nasty: remove func from Dict that's being called (works) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
499 func Test_dict_func_remove_in_use() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
500 let d = {1:1} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
501 func d.func(a) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
502 return "a:" . a:a |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
503 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
504 let expected = 'a:' . string(get(d, 'func')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
505 call assert_equal(expected, d.func(string(remove(d, 'func')))) |
25593
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
506 |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
507 " similar, in a way it also works in Vim9 |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
508 let lines =<< trim END |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
509 VAR d = {1: 1, 2: 'x'} |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
510 func GetArg(a) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
511 return "a:" .. a:a |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
512 endfunc |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
513 LET d.func = function('GetArg') |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
514 VAR expected = 'a:' .. string(get(d, 'func')) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
515 call assert_equal(expected, d.func(string(remove(d, 'func')))) |
c6277019b8c1
patch 8.2.3333: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25591
diff
changeset
|
516 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
517 call v9.CheckTransLegacySuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
518 call v9.CheckTransVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
519 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
520 |
17368
6604ecb7a615
patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents:
15949
diff
changeset
|
521 func Test_dict_literal_keys() |
17413
40417757dffd
patch 8.1.1705: using ~{} for a literal dict is not nice
Bram Moolenaar <Bram@vim.org>
parents:
17387
diff
changeset
|
522 call assert_equal({'one': 1, 'two2': 2, '3three': 3, '44': 4}, #{one: 1, two2: 2, 3three: 3, 44: 4},) |
17387
2558f90045e5
patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
17375
diff
changeset
|
523 |
25330
820395d1137b
patch 8.2.3202: Vim9: tests are only executed for legacy script
Bram Moolenaar <Bram@vim.org>
parents:
25308
diff
changeset
|
524 " why *{} cannot be used for a literal dictionary |
17387
2558f90045e5
patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
17375
diff
changeset
|
525 let blue = 'blue' |
2558f90045e5
patch 8.1.1692: using *{} for literal dict is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents:
17375
diff
changeset
|
526 call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue'))) |
17368
6604ecb7a615
patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents:
15949
diff
changeset
|
527 endfunc |
6604ecb7a615
patch 8.1.1683: dictionary with string keys is longer than needed
Bram Moolenaar <Bram@vim.org>
parents:
15949
diff
changeset
|
528 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
529 " Nasty: deepcopy() dict that refers to itself (fails when noref used) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
530 func Test_dict_deepcopy() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
531 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
532 VAR d = {1: 1, 2: '2'} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
533 VAR l = [4, d, 6] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
534 LET d[3] = l |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
535 VAR dc = deepcopy(d) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
536 call deepcopy(d, 1) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
537 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
538 call v9.CheckLegacyAndVim9Failure(lines, 'E698:') |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
539 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
540 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
541 VAR d = {1: 1, 2: '2'} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
542 VAR l = [4, d, 6] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
543 LET d[3] = l |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
544 VAR l2 = [0, l, l, 3] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
545 LET l[1] = l2 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
546 VAR l3 = deepcopy(l2) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
547 call assert_true(l3[1] is l3[2]) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
548 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
549 call v9.CheckLegacyAndVim9Success(lines) |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
550 |
22101
0ee66f232839
patch 8.2.1600: Vim9: cannot use "true" with deepcopy()
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
551 call assert_fails("call deepcopy([1, 2], 2)", 'E1023:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
552 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
553 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
554 " Locked variables |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
555 func Test_list_locked_var() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
556 " Not tested with :def function, local vars cannot be locked. |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
557 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
558 VAR expected = [ |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
559 \ [['1000-000', 'ppppppF'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
560 \ ['0000-000', 'ppppppp'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
561 \ ['0000-000', 'ppppppp']], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
562 \ [['1000-000', 'ppppppF'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
563 \ ['0000-000', 'ppppppp'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
564 \ ['0000-000', 'ppppppp']], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
565 \ [['1100-100', 'ppFppFF'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
566 \ ['0000-000', 'ppppppp'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
567 \ ['0000-000', 'ppppppp']], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
568 \ [['1110-110', 'pFFpFFF'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
569 \ ['0010-010', 'pFppFpp'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
570 \ ['0000-000', 'ppppppp']], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
571 \ [['1111-111', 'FFFFFFF'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
572 \ ['0011-011', 'FFpFFpp'], |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
573 \ ['0000-000', 'ppppppp']] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
574 \ ] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
575 for depth in range(5) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
576 for u in range(3) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
577 VAR l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
578 exe "lockvar " .. depth .. " l" |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
579 if u == 1 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
580 exe "unlockvar l" |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
581 elseif u == 2 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
582 exe "unlockvar " .. depth .. " l" |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
583 endif |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
584 VAR ps = islocked("l") .. islocked("l[1]") .. islocked("l[1][1]") .. islocked("l[1][1][0]") .. '-' .. islocked("l[2]") .. islocked("l[2]['6']") .. islocked("l[2]['6'][7]") |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
585 call assert_equal(expected[depth][u][0], ps, 'depth: ' .. depth) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
586 LET ps = '' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
587 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
588 LET l[1][1][0] = 99 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
589 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
590 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
591 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
592 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
593 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
594 LET l[1][1] = [99] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
595 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
596 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
597 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
598 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
599 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
600 LET l[1] = [99] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
601 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
602 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
603 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
604 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
605 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
606 LET l[2]['6'][7] = 99 |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
607 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
608 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
609 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
610 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
611 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
612 LET l[2][6] = {99: 99} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
613 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
614 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
615 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
616 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
617 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
618 LET l[2] = {99: 99} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
619 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
620 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
621 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
622 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
623 try |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
624 LET l = [99] |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
625 LET ps ..= 'p' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
626 catch |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
627 LET ps ..= 'F' |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
628 endtry |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
629 call assert_equal(expected[depth][u][1], ps, 'depth: ' .. depth) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
630 unlock! l |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
631 endfor |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
632 endfor |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
633 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
634 call v9.CheckTransLegacySuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
635 call v9.CheckTransVim9Success(lines) |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
636 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
637 call assert_fails("let x=islocked('a b')", 'E488:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
638 let mylist = [1, 2, 3] |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
639 call assert_fails("let x = islocked('mylist[1:2]')", 'E786:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
640 let mydict = {'k' : 'v'} |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
641 call assert_fails("let x = islocked('mydict.a')", 'E716:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
642 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
643 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
644 " Unletting locked variables |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
645 func Test_list_locked_var_unlet() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
646 " Not tested with Vim9: script and local variables cannot be unlocked |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
647 let expected = [ |
22298
07e48ee8c3bb
patch 8.2.1698: cannot lock a variable in legacy Vim script like in Vim9
Bram Moolenaar <Bram@vim.org>
parents:
22101
diff
changeset
|
648 \ [['1000-000', 'ppppppp'], |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
649 \ ['0000-000', 'ppppppp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
650 \ ['0000-000', 'ppppppp']], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
651 \ [['1000-000', 'ppFppFp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
652 \ ['0000-000', 'ppppppp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
653 \ ['0000-000', 'ppppppp']], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
654 \ [['1100-100', 'pFFpFFp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
655 \ ['0000-000', 'ppppppp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
656 \ ['0000-000', 'ppppppp']], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
657 \ [['1110-110', 'FFFFFFp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
658 \ ['0010-010', 'FppFppp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
659 \ ['0000-000', 'ppppppp']], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
660 \ [['1111-111', 'FFFFFFp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
661 \ ['0011-011', 'FppFppp'], |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
662 \ ['0000-000', 'ppppppp']] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
663 \ ] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
664 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
665 for depth in range(5) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
666 for u in range(3) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
667 unlet! l |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
668 let l = [0, [1, [2, 3]], {4: 5, 6: {7: 8}}] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
669 exe "lockvar " . depth . " l" |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
670 if u == 1 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
671 exe "unlockvar l" |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
672 elseif u == 2 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
673 exe "unlockvar " . depth . " l" |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
674 endif |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
675 let ps = islocked("l").islocked("l[1]").islocked("l[1][1]").islocked("l[1][1][0]").'-'.islocked("l[2]").islocked("l[2]['6']").islocked("l[2]['6'][7]") |
22298
07e48ee8c3bb
patch 8.2.1698: cannot lock a variable in legacy Vim script like in Vim9
Bram Moolenaar <Bram@vim.org>
parents:
22101
diff
changeset
|
676 call assert_equal(expected[depth][u][0], ps, 'depth: ' .. depth) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
677 let ps = '' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
678 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
679 unlet l[2]['6'][7] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
680 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
681 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
682 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
683 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
684 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
685 unlet l[2][6] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
686 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
687 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
688 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
689 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
690 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
691 unlet l[2] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
692 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
693 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
694 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
695 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
696 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
697 unlet l[1][1][0] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
698 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
699 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
700 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
701 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
702 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
703 unlet l[1][1] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
704 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
705 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
706 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
707 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
708 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
709 unlet l[1] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
710 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
711 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
712 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
713 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
714 try |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
715 unlet l |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
716 let ps .= 'p' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
717 catch |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
718 let ps .= 'F' |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
719 endtry |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
720 call assert_equal(expected[depth][u][1], ps) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
721 endfor |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
722 endfor |
26626
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
723 |
28152
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
27859
diff
changeset
|
724 " Deleting a list range with locked items works, but changing the items |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
27859
diff
changeset
|
725 " fails. |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24618
diff
changeset
|
726 let l = [1, 2, 3, 4] |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24618
diff
changeset
|
727 lockvar l[1:2] |
28152
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
27859
diff
changeset
|
728 call assert_fails('let l[1:2] = [8, 9]', 'E741:') |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
27859
diff
changeset
|
729 unlet l[1:2] |
b96409b84eaf
patch 8.2.4600: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
27859
diff
changeset
|
730 call assert_equal([1, 4], l) |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24618
diff
changeset
|
731 unlet l |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
732 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
733 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
734 " Locked variables and :unlet or list / dict functions |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
735 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
736 " No :unlet after lock on dict: |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
737 func Test_dict_lock_unlet() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
738 let d = {'a': 99, 'b': 100} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
739 lockvar 1 d |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
740 call assert_fails('unlet d.a', 'E741:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
741 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
742 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
743 " unlet after lock on dict item |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
744 func Test_dict_item_lock_unlet() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
745 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
746 VAR d = {'a': 99, 'b': 100} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
747 lockvar d.a |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
748 unlet d.a |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
749 call assert_equal({'b': 100}, d) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
750 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
751 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
752 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
753 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
754 " filter() after lock on dict item |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
755 func Test_dict_lock_filter() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
756 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
757 VAR d = {'a': 99, 'b': 100} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
758 lockvar d.a |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
759 call filter(d, 'v:key != "a"') |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
760 call assert_equal({'b': 100}, d) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
761 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
762 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
763 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
764 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
765 " map() after lock on dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
766 func Test_dict_lock_map() |
25595
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
767 let lines =<< trim END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
768 VAR d = {'a': 99, 'b': 100} |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
769 lockvar 1 d |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
770 call map(d, 'v:val + 200') |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
771 call assert_equal({'a': 299, 'b': 300}, d) |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
772 END |
c4e29355cd8b
patch 8.2.3334: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25593
diff
changeset
|
773 " This won't work in a :def function |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
774 call v9.CheckTransLegacySuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
775 call v9.CheckTransVim9Success(lines) |
26624
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
776 |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
777 " For a :def function use a global dict. |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
778 let lines =<< trim END |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
779 let g:thedict = {'a': 77, 'b': 88} |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
780 lockvar 1 g:thedict |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
781 def Delkey() |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
782 unlet g:thedict.a |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
783 enddef |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
784 call Delkey() |
bdf11d8e3df3
patch 8.2.3841: Vim9: outdated TODO items, disabled tests that work
Bram Moolenaar <Bram@vim.org>
parents:
26342
diff
changeset
|
785 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
786 call v9.CheckScriptFailure(lines, 'E741:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
787 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
788 |
26684
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
789 " Lock one item in a list |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
790 func Test_list_item_lock_map() |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
791 let lines =<< trim END |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
792 VAR l = [99, 100, 101] |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
793 lockvar l[1] |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
794 call assert_fails("echo map(l, 'v:val + 200')", 'E741:') |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
795 call assert_equal([299, 100, 101], l) |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
796 END |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
797 " This won't work in a :def function |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
798 call v9.CheckTransLegacySuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
799 call v9.CheckTransVim9Success(lines) |
26684
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
800 endfunc |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
801 |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
802 " Lock one item in a dict |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
803 func Test_dict_item_lock_map() |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
804 let lines =<< trim END |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
805 VAR d = {'a': 99, 'b': 100, 'c': 101} |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
806 lockvar d.b |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
807 call assert_fails("echo map(d, 'v:val + 200')", 'E741:') |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
808 call assert_equal({'a': 299, 'b': 100, 'c': 101}, d) |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
809 END |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
810 " This won't work in a :def function |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
811 call v9.CheckTransLegacySuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
812 call v9.CheckTransVim9Success(lines) |
26684
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
813 endfunc |
2126feddeda6
patch 8.2.3871: list.c contains code for dict and blob
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
814 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
815 " No extend() after lock on dict item |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
816 func Test_dict_lock_extend() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
817 let d = {'a': 99, 'b': 100} |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
818 lockvar d.a |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
819 call assert_fails("call extend(d, {'a' : 123})", 'E741:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
820 call assert_equal({'a': 99, 'b': 100}, d) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
821 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
822 |
20136
fdf94ab9929b
patch 8.2.0623: typo in test comment
Bram Moolenaar <Bram@vim.org>
parents:
20128
diff
changeset
|
823 " Cannot use += with a locked dict |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
824 func Test_dict_lock_operator() |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
825 let d = {} |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
826 lockvar d |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
827 call assert_fails("let d += {'k' : 10}", 'E741:') |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
828 unlockvar d |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
829 endfunc |
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
830 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
831 " No remove() of write-protected scope-level variable |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14856
diff
changeset
|
832 func Tfunc1(this_is_a_long_parameter_name) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
833 call assert_fails("call remove(a:, 'this_is_a_long_parameter_name')", 'E742:') |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14856
diff
changeset
|
834 endfunc |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
835 func Test_dict_scope_var_remove() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14856
diff
changeset
|
836 call Tfunc1('testval') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
837 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
838 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
839 " No extend() of write-protected scope-level variable |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
840 func Test_dict_scope_var_extend() |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
841 call assert_fails("call extend(a:, {'this_is_a_long_parameter_name': 1234})", 'E742:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
842 endfunc |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
843 |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14856
diff
changeset
|
844 func Tfunc2(this_is_a_long_parameter_name) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
845 call assert_fails("call extend(a:, {'this_is_a_long_parameter_name': 1234})", 'E742:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
846 endfunc |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
847 func Test_dict_scope_var_extend_overwrite() |
15406
63b02fcf1361
patch 8.1.0711: test files still use function!
Bram Moolenaar <Bram@vim.org>
parents:
14856
diff
changeset
|
848 call Tfunc2('testval') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
849 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
850 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
851 " No :unlet of variable in locked scope |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
852 func Test_lock_var_unlet() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
853 let b:testvar = 123 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
854 lockvar 1 b: |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
855 call assert_fails('unlet b:testvar', 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
856 unlockvar 1 b: |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
857 unlet! b:testvar |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
858 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
859 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
860 " No :let += of locked list variable |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
861 func Test_let_lock_list() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
862 let l = ['a', 'b', 3] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
863 lockvar 1 l |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
864 call assert_fails("let l += ['x']", 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
865 call assert_equal(['a', 'b', 3], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
866 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
867 unlet l |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
868 let l = [1, 2, 3, 4] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
869 lockvar! l |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
870 call assert_equal([1, 2, 3, 4], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
871 unlockvar l[1] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
872 call assert_fails('unlet l[0:1]', 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
873 call assert_equal([1, 2, 3, 4], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
874 call assert_fails('unlet l[1:2]', 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
875 call assert_equal([1, 2, 3, 4], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
876 unlockvar l[1] |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
877 call assert_fails('let l[0:1] = [0, 1]', 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
878 call assert_equal([1, 2, 3, 4], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
879 call assert_fails('let l[1:2] = [0, 1]', 'E741:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
880 call assert_equal([1, 2, 3, 4], l) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
881 unlet l |
26626
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
882 |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
883 let lines =<< trim END |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
884 def TryUnletListItem(l: list<any>) |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
885 unlet l[0] |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
886 enddef |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
887 let l = [1, 2, 3, 4] |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
888 lockvar! l |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
889 call TryUnletListItem(l) |
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
890 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
891 call v9.CheckScriptFailure(lines, 'E741:') |
26626
4d18b3a5254a
patch 8.2.3842: Vim9: can change locked list and list items
Bram Moolenaar <Bram@vim.org>
parents:
26624
diff
changeset
|
892 unlet g:l |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
893 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
894 |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
895 " Locking part of the list |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
896 func Test_let_lock_list_items() |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
897 let l = [1, 2, 3, 4] |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
898 lockvar l[2:] |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
899 call assert_equal(0, islocked('l[0]')) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
900 call assert_equal(1, islocked('l[2]')) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
901 call assert_equal(1, islocked('l[3]')) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
902 call assert_fails('let l[2] = 10', 'E741:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
903 call assert_fails('let l[3] = 20', 'E741:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
904 unlet l |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
905 endfunc |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
906 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
907 " lockvar/islocked() triggering script autoloading |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
908 func Test_lockvar_script_autoload() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
909 let old_rtp = &rtp |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
910 set rtp+=./sautest |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
911 lockvar g:footest#x |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
912 unlockvar g:footest#x |
17914
af3d441845cd
patch 8.1.1953: more functions can be used as a method
Bram Moolenaar <Bram@vim.org>
parents:
17413
diff
changeset
|
913 call assert_equal(-1, 'g:footest#x'->islocked()) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
914 call assert_equal(0, exists('g:footest#x')) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
915 call assert_equal(1, g:footest#x) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
916 let &rtp = old_rtp |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
917 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
918 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
919 " a:000 function argument test |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
920 func s:arg_list_test(...) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
921 call assert_fails('let a:000 = [1, 2]', 'E46:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
922 call assert_fails('let a:000[0] = 9', 'E742:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
923 call assert_fails('let a:000[2] = [9, 10]', 'E742:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
924 call assert_fails('let a:000[3] = {9 : 10}', 'E742:') |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
925 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
926 " now the tests that should pass |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
927 let a:000[2][1] = 9 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
928 call extend(a:000[2], [5, 6]) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
929 let a:000[3][5] = 8 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
930 let a:000[3]['a'] = 12 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
931 call assert_equal([1, 2, [3, 9, 5, 6], {'a': 12, '5': 8}], a:000) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
932 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
933 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
934 func Test_func_arg_list() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
935 call s:arg_list_test(1, 2, [3, 4], {5: 6}) |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
936 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
937 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
938 " Tests for reverse(), sort(), uniq() |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
939 func Test_reverse_sort_uniq() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
940 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
941 VAR l = ['-0', 'A11', 2, 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
942 call assert_equal(['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5], uniq(copy(l))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
943 call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
944 call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(reverse(l))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
945 if has('float') |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
946 call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
947 call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
948 call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l)))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
949 call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l))) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
950 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
951 LET l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four'] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
952 call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
953 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
954 LET l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] |
27859
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
955 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
956 call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
957 call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
958 endif |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
959 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
960 call v9.CheckLegacyAndVim9Success(lines) |
15571
4af72c724093
patch 8.1.0793: incorrect error messages for functions that take a Blob
Bram Moolenaar <Bram@vim.org>
parents:
15406
diff
changeset
|
961 |
15579
391ac26c9412
patch 8.1.0797: error E898 is used twice
Bram Moolenaar <Bram@vim.org>
parents:
15571
diff
changeset
|
962 call assert_fails('call reverse("")', 'E899:') |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21064
diff
changeset
|
963 call assert_fails('call uniq([1, 2], {x, y -> []})', 'E745:') |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
964 call assert_fails("call sort([1, 2], function('min'), 1)", "E715:") |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
965 call assert_fails("call sort([1, 2], function('invalid_func'))", "E700:") |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21064
diff
changeset
|
966 call assert_fails("call sort([1, 2], function('min'))", "E118:") |
27859
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
967 |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
968 let lines =<< trim END |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
969 call sort(['a', 'b'], 0) |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
970 END |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
971 call v9.CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
972 |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
973 let lines =<< trim END |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
974 call sort(['a', 'b'], 1) |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
975 END |
3cb1a109e987
patch 8.2.4455: accepting one and zero for second sort() argument is strange
Bram Moolenaar <Bram@vim.org>
parents:
27851
diff
changeset
|
976 call v9.CheckDefAndScriptFailure(lines, 'E1256: String or function required for argument 2') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
977 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
978 |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
979 " reduce a list, blob or string |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
980 func Test_reduce() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
981 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
982 call assert_equal(1, reduce([], LSTART acc, val LMIDDLE acc + val LEND, 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
983 call assert_equal(10, reduce([1, 3, 5], LSTART acc, val LMIDDLE acc + val LEND, 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
984 call assert_equal(2 * (2 * ((2 * 1) + 2) + 3) + 4, reduce([2, 3, 4], LSTART acc, val LMIDDLE 2 * acc + val LEND, 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
985 call assert_equal('a x y z', ['x', 'y', 'z']->reduce(LSTART acc, val LMIDDLE acc .. ' ' .. val LEND, 'a')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
986 call assert_equal([0, 1, 2, 3], reduce([1, 2, 3], function('add'), [0])) |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
987 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
988 VAR l = ['x', 'y', 'z'] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
989 call assert_equal(42, reduce(l, function('get'), {'x': {'y': {'z': 42 } } })) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
990 call assert_equal(['x', 'y', 'z'], l) |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
991 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
992 call assert_equal(1, reduce([1], LSTART acc, val LMIDDLE acc + val LEND)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
993 call assert_equal('x y z', reduce(['x', 'y', 'z'], LSTART acc, val LMIDDLE acc .. ' ' .. val LEND)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
994 call assert_equal(120, range(1, 5)->reduce(LSTART acc, val LMIDDLE acc * val LEND)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
995 |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
996 call assert_equal(1, reduce(0z, LSTART acc, val LMIDDLE acc + val LEND, 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
997 call assert_equal(1 + 0xaf + 0xbf + 0xcf, reduce(0zAFBFCF, LSTART acc, val LMIDDLE acc + val LEND, 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
998 call assert_equal(2 * (2 * 1 + 0xaf) + 0xbf, 0zAFBF->reduce(LSTART acc, val LMIDDLE 2 * acc + val LEND, 1)) |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
999 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1000 call assert_equal(0xff, reduce(0zff, LSTART acc, val LMIDDLE acc + val LEND)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1001 call assert_equal(2 * (2 * 0xaf + 0xbf) + 0xcf, reduce(0zAFBFCF, LSTART acc, val LMIDDLE 2 * acc + val LEND)) |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1002 |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1003 call assert_equal('x,y,z', 'xyz'->reduce(LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1004 call assert_equal('', ''->reduce(LSTART acc, val LMIDDLE acc .. ',' .. val LEND, '')) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1005 call assert_equal('あ,い,う,え,お,😊,💕', 'あいうえお😊💕'->reduce(LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1006 call assert_equal('😊,あ,い,う,え,お,💕', 'あいうえお💕'->reduce(LSTART acc, val LMIDDLE acc .. ',' .. val LEND, '😊')) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1007 call assert_equal('ऊ,ॠ,ॡ', reduce('ऊॠॡ', LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1008 call assert_equal('c,à,t', reduce('càt', LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1009 call assert_equal('Å,s,t,r,ö,m', reduce('Åström', LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1010 call assert_equal('Å,s,t,r,ö,m', reduce('Åström', LSTART acc, val LMIDDLE acc .. ',' .. val LEND)) |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1011 call assert_equal(',a,b,c', reduce('abc', LSTART acc, val LMIDDLE acc .. ',' .. val LEND, test_null_string())) |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1012 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1013 call v9.CheckLegacyAndVim9Success(lines) |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1014 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1015 call assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce({ acc, val -> extend(acc, { val: 1 }) }, {})) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1016 vim9 assert_equal({'x': 1, 'y': 1, 'z': 1 }, ['x', 'y', 'z']->reduce((acc, val) => extend(acc, {[val]: 1 }), {})) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1017 |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1018 call assert_fails("call reduce([], { acc, val -> acc + val })", 'E998: Reduce of an empty List with no initial value') |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1019 call assert_fails("call reduce(0z, { acc, val -> acc + val })", 'E998: Reduce of an empty Blob with no initial value') |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
1020 call assert_fails("call reduce(test_null_blob(), { acc, val -> acc + val })", 'E998: Reduce of an empty Blob with no initial value') |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1021 call assert_fails("call reduce('', { acc, val -> acc + val })", 'E998: Reduce of an empty String with no initial value') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1022 call assert_fails("call reduce(test_null_string(), { acc, val -> acc + val })", 'E998: Reduce of an empty String with no initial value') |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1023 |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1024 call assert_fails("call reduce({}, { acc, val -> acc + val }, 1)", 'E1098:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1025 call assert_fails("call reduce(0, { acc, val -> acc + val }, 1)", 'E1098:') |
22510
7060df0b8ebf
patch 8.2.1803: a few failures are not tested
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
1026 call assert_fails("call reduce([1, 2], 'Xdoes_not_exist')", 'E117:') |
7060df0b8ebf
patch 8.2.1803: a few failures are not tested
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
1027 call assert_fails("echo reduce(0z01, { acc, val -> 2 * acc + val }, '')", 'E39:') |
21000
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1028 |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1029 call assert_fails("vim9 reduce(0, (acc, val) => (acc .. val), '')", 'E1252:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1030 call assert_fails("vim9 reduce({}, (acc, val) => (acc .. val), '')", 'E1252:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1031 call assert_fails("vim9 reduce(0.1, (acc, val) => (acc .. val), '')", 'E1252:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1032 call assert_fails("vim9 reduce(function('tr'), (acc, val) => (acc .. val), '')", 'E1252:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1033 call assert_fails("call reduce('', { acc, val -> acc + val }, 1)", 'E1253:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1034 call assert_fails("call reduce('', { acc, val -> acc + val }, {})", 'E1253:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1035 call assert_fails("call reduce('', { acc, val -> acc + val }, 0.1)", 'E1253:') |
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1036 call assert_fails("call reduce('', { acc, val -> acc + val }, function('tr'))", 'E1253:') |
26640
7c055fdd6200
patch 8.2.3849: functions implementing reduce and map are too long
Bram Moolenaar <Bram@vim.org>
parents:
26638
diff
changeset
|
1037 call assert_fails("call reduce('abc', { a, v -> a10}, '')", 'E121:') |
28570
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
1038 call assert_fails("call reduce(0z0102, { a, v -> a10}, 1)", 'E121:') |
35e24d9de858
patch 8.2.4809: various things no6 properly tested
Bram Moolenaar <Bram@vim.org>
parents:
28152
diff
changeset
|
1039 call assert_fails("call reduce([1, 2], { a, v -> a10}, '')", 'E121:') |
26638
6fd15d82e898
patch 8.2.3848: cannot use reduce() for a string
Bram Moolenaar <Bram@vim.org>
parents:
26626
diff
changeset
|
1040 |
21000
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1041 let g:lut = [1, 2, 3, 4] |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1042 func EvilRemove() |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1043 call remove(g:lut, 1) |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1044 return 1 |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1045 endfunc |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1046 call assert_fails("call reduce(g:lut, { acc, val -> EvilRemove() }, 1)", 'E742:') |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1047 unlet g:lut |
3b29ac3394dc
patch 8.2.1051: crash when changing a list while using reduce() on it
Bram Moolenaar <Bram@vim.org>
parents:
20649
diff
changeset
|
1048 delfunc EvilRemove |
21064
6dc8625889fe
patch 8.2.1083: crash when using reduce() on a NULL list
Bram Moolenaar <Bram@vim.org>
parents:
21000
diff
changeset
|
1049 |
6dc8625889fe
patch 8.2.1083: crash when using reduce() on a NULL list
Bram Moolenaar <Bram@vim.org>
parents:
21000
diff
changeset
|
1050 call assert_equal(42, reduce(test_null_list(), function('add'), 42)) |
6dc8625889fe
patch 8.2.1083: crash when using reduce() on a NULL list
Bram Moolenaar <Bram@vim.org>
parents:
21000
diff
changeset
|
1051 call assert_equal(42, reduce(test_null_blob(), function('add'), 42)) |
22794
42bb78d46354
patch 8.2.1945: crash when passing NULL function to reduce()
Bram Moolenaar <Bram@vim.org>
parents:
22754
diff
changeset
|
1052 |
42bb78d46354
patch 8.2.1945: crash when passing NULL function to reduce()
Bram Moolenaar <Bram@vim.org>
parents:
22754
diff
changeset
|
1053 " should not crash |
42bb78d46354
patch 8.2.1945: crash when passing NULL function to reduce()
Bram Moolenaar <Bram@vim.org>
parents:
22754
diff
changeset
|
1054 call assert_fails('echo reduce([1], test_null_function())', 'E1132:') |
24618
4aebea72c397
patch 8.2.2848: crash whn calling partial
Bram Moolenaar <Bram@vim.org>
parents:
24396
diff
changeset
|
1055 call assert_fails('echo reduce([1], test_null_partial())', 'E1132:') |
20649
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1056 endfunc |
1fa0ace0ba65
patch 8.2.0878: no reduce() function
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
1057 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
1058 " splitting a string to a List using split() |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1059 func Test_str_split() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1060 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1061 call assert_equal(['aa', 'bb'], split(' aa bb ')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1062 call assert_equal(['aa', 'bb'], split(' aa bb ', '\W\+', 0)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1063 call assert_equal(['', 'aa', 'bb', ''], split(' aa bb ', '\W\+', 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1064 call assert_equal(['', '', 'aa', '', 'bb', '', ''], split(' aa bb ', '\W', 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1065 call assert_equal(['aa', '', 'bb'], split(':aa::bb:', ':', 0)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1066 call assert_equal(['', 'aa', '', 'bb', ''], split(':aa::bb:', ':', 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1067 call assert_equal(['aa', '', 'bb', 'cc', ''], split('aa,,bb, cc,', ',\s*', 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1068 call assert_equal(['a', 'b', 'c'], split('abc', '\zs')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1069 call assert_equal(['', 'a', '', 'b', '', 'c', ''], split('abc', '\zs', 1)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1070 call assert_equal(['abc'], split('abc', '\\%(')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1071 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1072 call v9.CheckLegacyAndVim9Success(lines) |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1073 |
19783
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
1074 call assert_fails("call split('abc', [])", 'E730:') |
546bdeef35f1
patch 8.2.0448: various functions not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
19724
diff
changeset
|
1075 call assert_fails("call split('abc', 'b', [])", 'E745:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1076 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1077 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1078 " compare recursively linked list and dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1079 func Test_listdict_compare() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1080 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1081 VAR l = [1, 2, 3, '4'] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1082 VAR d = {'1': 1, '2': l, '3': 3} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1083 LET l[1] = d |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1084 call assert_true(l == l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1085 call assert_true(d == d) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1086 call assert_false(l != deepcopy(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1087 call assert_false(d != deepcopy(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1088 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1089 call v9.CheckLegacyAndVim9Success(lines) |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1090 |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1091 " comparison errors |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1092 call assert_fails('echo [1, 2] =~ {}', 'E691:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1093 call assert_fails('echo [1, 2] =~ [1, 2]', 'E692:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1094 call assert_fails('echo {} =~ 5', 'E735:') |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1095 call assert_fails('echo {} =~ {}', 'E736:') |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1096 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1097 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1098 " compare complex recursively linked list and dict |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1099 func Test_listdict_compare_complex() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1100 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1101 VAR l = [] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1102 call add(l, l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1103 VAR dict4 = {"l": l} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1104 call add(dict4.l, dict4) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1105 VAR lcopy = deepcopy(l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1106 VAR dict4copy = deepcopy(dict4) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1107 call assert_true(l == lcopy) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1108 call assert_true(dict4 == dict4copy) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1109 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1110 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1111 endfunc |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1112 |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1113 " Test for extending lists and dictionaries |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1114 func Test_listdict_extend() |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1115 " Test extend() with lists |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1116 |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1117 " Pass the same List to extend() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1118 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1119 VAR l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1120 call assert_equal([1, 2, 3, 1, 2, 3], extend(l, l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1121 call assert_equal([1, 2, 3, 1, 2, 3], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1122 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1123 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1124 call assert_equal([1, 2, 3, 4, 5, 6], extend(l, [4, 5, 6])) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1125 call assert_equal([1, 2, 3, 4, 5, 6], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1126 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1127 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1128 call extend(l, [4, 5, 6], 0) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1129 call assert_equal([4, 5, 6, 1, 2, 3], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1130 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1131 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1132 call extend(l, [4, 5, 6], 1) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1133 call assert_equal([1, 4, 5, 6, 2, 3], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1134 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1135 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1136 call extend(l, [4, 5, 6], 3) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1137 call assert_equal([1, 2, 3, 4, 5, 6], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1138 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1139 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1140 call extend(l, [4, 5, 6], -1) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1141 call assert_equal([1, 2, 4, 5, 6, 3], l) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1142 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1143 LET l = [1, 2, 3] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1144 call extend(l, [4, 5, 6], -3) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1145 call assert_equal([4, 5, 6, 1, 2, 3], l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1146 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1147 call v9.CheckLegacyAndVim9Success(lines) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1148 |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1149 let l = [1, 2, 3] |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1150 call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:') |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1151 call assert_fails("call extend(l, [4, 5, 6], -4)", 'E684:') |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
1152 if has('float') |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
1153 call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:') |
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
1154 endif |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1155 |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1156 " Test extend() with dictionaries. |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1157 |
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1158 " Pass the same Dict to extend() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1159 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1160 VAR d = {'a': {'b': 'B'}, 'x': 9} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1161 call extend(d, d) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1162 call assert_equal({'a': {'b': 'B'}, 'x': 9}, d) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1163 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1164 LET d = {'a': 'A', 'b': 9} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1165 call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, extend(d, {'b': 0, 'c': 'C'})) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1166 call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1167 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1168 LET d = {'a': 'A', 'b': 9} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1169 call extend(d, {'a': 'A', 'b': 0, 'c': 'C'}, "force") |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1170 call assert_equal({'a': 'A', 'b': 0, 'c': 'C'}, d) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1171 |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1172 LET d = {'a': 'A', 'b': 9} |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1173 call extend(d, {'b': 0, 'c': 'C'}, "keep") |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1174 call assert_equal({'a': 'A', 'b': 9, 'c': 'C'}, d) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1175 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1176 call v9.CheckLegacyAndVim9Success(lines) |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1177 |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1178 let d = {'a': 'A', 'b': 'B'} |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1179 call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:') |
26759
31c23760d590
patch 8.2.3908: cannot use a script-local function for 'foldtext'
Bram Moolenaar <Bram@vim.org>
parents:
26684
diff
changeset
|
1180 call assert_fails("call extend(d, {'b': 0}, [])", 'E730:') |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1181 call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:') |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
1182 if has('float') |
24822
5f8dd7b3ae41
patch 8.2.2949: tests failing because no error for float to string conversion
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
1183 call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E475:') |
19249
2a017e9dc6da
patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents:
17914
diff
changeset
|
1184 endif |
15949
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1185 call assert_equal({'a': 'A', 'b': 'B'}, d) |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1186 |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1187 call assert_fails("call extend([1, 2], 1)", 'E712:') |
d8ab4fa99341
patch 8.1.0980: extend() insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
15762
diff
changeset
|
1188 call assert_fails("call extend([1, 2], {})", 'E712:') |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1189 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1190 " Extend g: dictionary with an invalid variable name |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1191 call assert_fails("call extend(g:, {'-!' : 10})", 'E461:') |
24396
d406858354a6
patch 8.2.2738: extending a list with itself can give wrong result
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
1192 |
d406858354a6
patch 8.2.2738: extending a list with itself can give wrong result
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
1193 " Extend a list with itself. |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1194 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1195 VAR l = [1, 5, 7] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1196 call extend(l, l, 0) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1197 call assert_equal([1, 5, 7, 1, 5, 7], l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1198 LET l = [1, 5, 7] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1199 call extend(l, l, 1) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1200 call assert_equal([1, 1, 5, 7, 5, 7], l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1201 LET l = [1, 5, 7] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1202 call extend(l, l, 2) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1203 call assert_equal([1, 5, 1, 5, 7, 7], l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1204 LET l = [1, 5, 7] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1205 call extend(l, l, 3) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1206 call assert_equal([1, 5, 7, 1, 5, 7], l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1207 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1208 call v9.CheckLegacyAndVim9Success(lines) |
12788
cb9b2774f21f
patch 8.0.1271: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1209 endfunc |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1210 |
23588
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1211 func Test_listdict_extendnew() |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1212 " Test extendnew() with lists |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1213 let l = [1, 2, 3] |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1214 call assert_equal([1, 2, 3, 4, 5], extendnew(l, [4, 5])) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1215 call assert_equal([1, 2, 3], l) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1216 |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1217 " Test extend() with dictionaries. |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1218 let d = {'a': {'b': 'B'}} |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1219 call assert_equal({'a': {'b': 'B'}, 'c': 'cc'}, extendnew(d, {'c': 'cc'})) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1220 call assert_equal({'a': {'b': 'B'}}, d) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1221 endfunc |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
22806
diff
changeset
|
1222 |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1223 func s:check_scope_dict(x, fixed) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1224 func s:gen_cmd(cmd, x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1225 return substitute(a:cmd, '\<x\ze:', a:x, 'g') |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1226 endfunc |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1227 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1228 let cmd = s:gen_cmd('let x:foo = 1', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1229 if a:fixed |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1230 call assert_fails(cmd, 'E461:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1231 else |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1232 exe cmd |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1233 exe s:gen_cmd('call assert_equal(1, x:foo)', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1234 endif |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1235 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1236 let cmd = s:gen_cmd('let x:["bar"] = 2', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1237 if a:fixed |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1238 call assert_fails(cmd, 'E461:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1239 else |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1240 exe cmd |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1241 exe s:gen_cmd('call assert_equal(2, x:bar)', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1242 endif |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1243 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1244 let cmd = s:gen_cmd('call extend(x:, {"baz": 3})', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1245 if a:fixed |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1246 call assert_fails(cmd, 'E742:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1247 else |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1248 exe cmd |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1249 exe s:gen_cmd('call assert_equal(3, x:baz)', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1250 endif |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1251 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1252 if a:fixed |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1253 if a:x ==# 'a' |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1254 call assert_fails('unlet a:x', 'E795:') |
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1255 call assert_fails('call remove(a:, "x")', 'E742:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1256 elseif a:x ==# 'v' |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1257 call assert_fails('unlet v:count', 'E795:') |
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21556
diff
changeset
|
1258 call assert_fails('call remove(v:, "count")', 'E742:') |
15762
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1259 endif |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1260 else |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1261 exe s:gen_cmd('unlet x:foo', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1262 exe s:gen_cmd('unlet x:bar', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1263 exe s:gen_cmd('call remove(x:, "baz")', a:x) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1264 endif |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1265 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1266 delfunc s:gen_cmd |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1267 endfunc |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1268 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1269 func Test_scope_dict() |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1270 " Test for g: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1271 call s:check_scope_dict('g', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1272 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1273 " Test for s: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1274 call s:check_scope_dict('s', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1275 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1276 " Test for l: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1277 call s:check_scope_dict('l', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1278 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1279 " Test for a: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1280 call s:check_scope_dict('a', v:true) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1281 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1282 " Test for b: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1283 call s:check_scope_dict('b', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1284 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1285 " Test for w: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1286 call s:check_scope_dict('w', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1287 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1288 " Test for t: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1289 call s:check_scope_dict('t', v:false) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1290 |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1291 " Test for v: |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1292 call s:check_scope_dict('v', v:true) |
dff66c4670b1
patch 8.1.0888: the a: dict is not immutable as documented
Bram Moolenaar <Bram@vim.org>
parents:
15579
diff
changeset
|
1293 endfunc |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1294 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1295 " Test for deep nesting of lists (> 100) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1296 func Test_deep_nested_list() |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1297 let deep_list = [] |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1298 let l = deep_list |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1299 for i in range(102) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1300 let newlist = [] |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1301 call add(l, newlist) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1302 let l = newlist |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1303 endfor |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1304 call add(l, 102) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1305 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1306 call assert_fails('let m = deepcopy(deep_list)', 'E698:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1307 call assert_fails('lockvar 110 deep_list', 'E743:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1308 call assert_fails('unlockvar 110 deep_list', 'E743:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1309 call assert_fails('let x = execute("echo deep_list")', 'E724:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1310 call test_garbagecollect_now() |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1311 unlet deep_list |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1312 endfunc |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1313 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1314 " Test for deep nesting of dicts (> 100) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1315 func Test_deep_nested_dict() |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1316 let deep_dict = {} |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1317 let d = deep_dict |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1318 for i in range(102) |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1319 let newdict = {} |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1320 let d.k = newdict |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1321 let d = newdict |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1322 endfor |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1323 let d.k = 'v' |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1324 |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1325 call assert_fails('let m = deepcopy(deep_dict)', 'E698:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1326 call assert_fails('lockvar 110 deep_dict', 'E743:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1327 call assert_fails('unlockvar 110 deep_dict', 'E743:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1328 call assert_fails('let x = execute("echo deep_dict")', 'E724:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1329 call test_garbagecollect_now() |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1330 unlet deep_dict |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1331 endfunc |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1332 |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1333 " List and dict indexing tests |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1334 func Test_listdict_index() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1335 call v9.CheckLegacyAndVim9Failure(['echo function("min")[0]'], 'E695:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1336 call v9.CheckLegacyAndVim9Failure(['echo v:true[0]'], 'E909:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1337 call v9.CheckLegacyAndVim9Failure(['echo v:null[0]'], 'E909:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1338 call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d.'], ['E15:', 'E1127:', 'E15:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1339 call v9.CheckLegacyAndVim9Failure(['VAR d = {"k": 10}', 'echo d[1 : 2]'], 'E719:') |
26646
6f8d3470fa90
patch 8.2.3852: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26640
diff
changeset
|
1340 |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1341 call assert_fails("let v = [4, 6][{-> 1}]", 'E729:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1342 call v9.CheckDefAndScriptFailure(['var v = [4, 6][() => 1]'], ['E1012', 'E703:']) |
26646
6f8d3470fa90
patch 8.2.3852: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26640
diff
changeset
|
1343 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1344 call v9.CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : []]'], ['E730:', 'E1012:', 'E730:']) |
26648
49c240ea23f4
patch 8.2.3853: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26646
diff
changeset
|
1345 |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21064
diff
changeset
|
1346 call assert_fails("let v = range(5)[2:{-> 2}(]", ['E15:', 'E116:']) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1347 call v9.CheckDefAndScriptFailure(['var v = range(5)[2 : () => 2(]'], 'E15:') |
26648
49c240ea23f4
patch 8.2.3853: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26646
diff
changeset
|
1348 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1349 call v9.CheckLegacyAndVim9Failure(['VAR v = range(5)[2 : 3'], ['E111:', 'E1097:', 'E111:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1350 call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, 10)'], 'E684:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1351 call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, -10)'], 'E684:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1352 call v9.CheckLegacyAndVim9Failure(['VAR l = insert([1, 2, 3], 4, [])'], ['E745:', 'E1013:', 'E1210:']) |
26648
49c240ea23f4
patch 8.2.3853: Vim9: not enough tests
Bram Moolenaar <Bram@vim.org>
parents:
26646
diff
changeset
|
1353 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1354 call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[i] = 3'], ['E121:', 'E1001:', 'E121:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1355 call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[1.1] = 4'], ['E805:', 'E1012:', 'E805:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1356 call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: i] = [4, 5]'], ['E121:', 'E1001:', 'E121:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1357 call v9.CheckLegacyAndVim9Failure(['VAR l = [1, 2, 3]', 'LET l[: 3.2] = [4, 5]'], ['E805:', 'E1012:', 'E805:']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1358 call v9.CheckLegacyAndVim9Failure(['VAR t = test_unknown()', 'echo t[0]'], 'E685:') |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1359 endfunc |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1360 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1361 " Test for a null list |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1362 func Test_null_list() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1363 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1364 VAR l = test_null_list() |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1365 call assert_equal('', join(test_null_list())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1366 call assert_equal('', join(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1367 call assert_equal(0, len(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1368 call assert_equal(1, empty(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1369 call assert_equal([], split(test_null_string())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1370 call assert_equal([], l[ : 2]) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1371 call assert_true([] == l) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1372 call assert_equal('[]', string(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1373 call assert_equal([], sort(test_null_list())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1374 call assert_equal([], sort(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1375 call assert_equal([], uniq(test_null_list())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1376 call assert_equal([], uniq(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1377 VAR k = [] + l |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1378 call assert_equal([], k) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1379 LET k = l + [] |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1380 call assert_equal([], k) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1381 call assert_equal(0, len(copy(l))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1382 call assert_equal(0, count(l, 5)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1383 call assert_equal([], deepcopy(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1384 call assert_equal(5, get(l, 2, 5)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1385 call assert_equal(-1, index(l, 2, 5)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1386 call assert_equal(0, min(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1387 call assert_equal(0, max(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1388 call assert_equal(0, remove(test_null_list(), 0, 2)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1389 call assert_equal([], repeat(l, 2)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1390 call assert_equal([], reverse(test_null_list())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1391 call assert_equal([], reverse(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1392 call assert_equal([], sort(test_null_list())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1393 call assert_equal([], sort(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1394 call assert_equal('[]', string(l)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1395 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1396 call v9.CheckLegacyAndVim9Success(lines) |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1397 |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
1398 let l = test_null_list() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1399 call assert_equal([], extend(l, l, 0)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1400 call assert_equal(0, insert(test_null_list(), 2, -1)) |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1401 call assert_fails('let s = join([1, 2], [])', 'E730:') |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1402 call assert_fails('call remove(l, 0, 2)', 'E684:') |
22806
690b84a6a7ce
patch 8.2.1951: test for list and dict fails
Bram Moolenaar <Bram@vim.org>
parents:
22794
diff
changeset
|
1403 call assert_fails('call insert(l, 2, -1)', 'E684:') |
690b84a6a7ce
patch 8.2.1951: test for list and dict fails
Bram Moolenaar <Bram@vim.org>
parents:
22794
diff
changeset
|
1404 call assert_fails('call extend(test_null_list(), test_null_list())', 'E1134:') |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1405 |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1406 lockvar l |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1407 call assert_equal(1, islocked('l')) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1408 unlockvar l |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1409 endfunc |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1410 |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1411 " Test for a null dict |
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
1412 func Test_null_dict() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1413 let lines =<< trim END |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1414 call assert_equal(test_null_dict(), test_null_dict()) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1415 VAR d = test_null_dict() |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1416 call assert_equal({}, d) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1417 call assert_equal(0, len(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1418 call assert_equal(1, empty(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1419 call assert_equal([], items(test_null_dict())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1420 call assert_equal([], items(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1421 call assert_equal([], keys(test_null_dict())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1422 call assert_equal([], keys(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1423 call assert_equal([], values(test_null_dict())) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1424 call assert_equal([], values(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1425 call assert_false(has_key(d, 'k')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1426 call assert_equal('{}', string(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1427 call assert_equal({}, {}) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1428 call assert_equal(0, len(copy(d))) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1429 call assert_equal(0, count(d, 'k')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1430 call assert_equal({}, deepcopy(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1431 call assert_equal(20, get(d, 'k', 20)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1432 call assert_equal(0, min(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1433 call assert_equal(0, max(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1434 call assert_equal(0, remove(test_null_dict(), 'k')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1435 call assert_equal('{}', string(d)) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1436 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26759
diff
changeset
|
1437 call v9.CheckLegacyAndVim9Success(lines) |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1438 |
20128
0b35a7ffceb2
patch 8.2.0619: null dict is not handled like an empty dict
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
1439 let d = test_null_dict() |
25597
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1440 call assert_equal({}, extend(d, d, 'keep')) |
0fdacd8f0cf3
patch 8.2.3335: Vim9: not enough tests run with Vim9
Bram Moolenaar <Bram@vim.org>
parents:
25595
diff
changeset
|
1441 call assert_fails("call remove(d, 'k')", 'E716:') |
22806
690b84a6a7ce
patch 8.2.1951: test for list and dict fails
Bram Moolenaar <Bram@vim.org>
parents:
22794
diff
changeset
|
1442 call assert_fails('let x = d[10]', 'E716:') |
690b84a6a7ce
patch 8.2.1951: test for list and dict fails
Bram Moolenaar <Bram@vim.org>
parents:
22794
diff
changeset
|
1443 call assert_fails('call extend(test_null_dict(), test_null_dict())', 'E1133:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1444 lockvar d |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1445 call assert_equal(1, islocked('d')) |
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20156
diff
changeset
|
1446 unlockvar d |
19724
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1447 endfunc |
b3e93a05c3ca
patch 8.2.0418: code in eval.c not sufficiently covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
1448 |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
1449 " vim: shiftwidth=2 sts=2 expandtab |