Mercurial > vim
annotate src/testdir/test_vim9_builtin.vim @ 24882:4c1b6f3eb96b v8.2.2979
patch 8.2.2979: not all options code is covered by tests
Commit: https://github.com/vim/vim/commit/5958549760652c173b703613b9cbf09b25a4eddb
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sat Jun 12 13:46:41 2021 +0200
patch 8.2.2979: not all options code is covered by tests
Problem: Not all options code is covered by tests.
Solution: Add more tests for options. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8369)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Jun 2021 14:00:04 +0200 |
parents | 8fdf839af1f4 |
children | b11f38f77006 |
rev | line source |
---|---|
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test using builtin functions in the Vim9 script language. |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 source check.vim |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 source vim9.vim |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 " Test for passing too many or too few arguments to builtin functions |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 func Test_internalfunc_arg_error() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 let l =<< trim END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 def! FArgErr(): float |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 return ceil(1.1, 2) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 defcompile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 call writefile(l, 'Xinvalidarg') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 call assert_fails('so Xinvalidarg', 'E118:', '', 1, 'FArgErr') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 let l =<< trim END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 def! FArgErr(): float |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 return ceil() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 defcompile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 call writefile(l, 'Xinvalidarg') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 call assert_fails('so Xinvalidarg', 'E119:', '', 1, 'FArgErr') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 call delete('Xinvalidarg') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 endfunc |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 " Test for builtin functions returning different types |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 func Test_InternalFuncRetType() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 let lines =<< trim END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 def RetFloat(): float |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 return ceil(1.456) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 def RetListAny(): list<any> |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
35 return items({k: 'v'}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 def RetListString(): list<string> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 return split('a:b:c', ':') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 def RetListDictAny(): list<dict<any>> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 return getbufinfo() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 def RetDictNumber(): dict<number> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 return wordcount() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 def RetDictString(): dict<string> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 return environ() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 call writefile(lines, 'Xscript') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 source Xscript |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 call RetFloat()->assert_equal(2.0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 call RetListAny()->assert_equal([['k', 'v']]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 call RetListString()->assert_equal(['a', 'b', 'c']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 call RetListDictAny()->assert_notequal([]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 call RetDictNumber()->assert_notequal({}) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 call RetDictString()->assert_notequal({}) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 call delete('Xscript') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 endfunc |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 def Test_abs() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 assert_equal(0, abs(0)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 assert_equal(2, abs(-2)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 assert_equal(3, abs(3)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 CheckDefFailure(['abs("text")'], 'E1013: Argument 1: type mismatch, expected number but got string', 1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 if has('float') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 assert_equal(0, abs(0)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 assert_equal(2.0, abs(-2.0)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 assert_equal(3.0, abs(3.0)) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 endif |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 def Test_add_list() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 var l: list<number> # defaults to empty list |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 add(l, 9) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 assert_equal([9], l) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 var lines =<< trim END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 var l: list<number> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 add(l, "x") |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 CheckDefFailure(lines, 'E1012:', 2) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 lines =<< trim END |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
90 add(test_null_list(), 123) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
91 END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
92 CheckDefExecAndScriptFailure(lines, 'E1130:', 1) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
93 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
94 lines =<< trim END |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 var l: list<number> = test_null_list() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 add(l, 123) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 CheckDefExecFailure(lines, 'E1130:', 2) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
99 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
100 # Getting variable with NULL list allocates a new list at script level |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
101 lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
102 vim9script |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
103 var l: list<number> = test_null_list() |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
104 add(l, 123) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
105 END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
106 CheckScriptSuccess(lines) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 def Test_add_blob() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 var b1: blob = 0z12 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 add(b1, 0x34) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 assert_equal(0z1234, b1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 var b2: blob # defaults to empty blob |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 add(b2, 0x67) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 assert_equal(0z67, b2) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 var lines =<< trim END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 var b: blob |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 add(b, "x") |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 CheckDefFailure(lines, 'E1012:', 2) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 lines =<< trim END |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
125 add(test_null_blob(), 123) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
126 END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
127 CheckDefExecAndScriptFailure(lines, 'E1131:', 1) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
128 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
129 lines =<< trim END |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 var b: blob = test_null_blob() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 add(b, 123) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 END |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 CheckDefExecFailure(lines, 'E1131:', 2) |
24482
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
134 |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
135 # Getting variable with NULL blob allocates a new blob at script level |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
136 lines =<< trim END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
137 vim9script |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
138 var b: blob = test_null_blob() |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
139 add(b, 123) |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
140 END |
3d5a66e478f8
patch 8.2.2781: add() silently skips when adding to null list or blob
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
141 CheckScriptSuccess(lines) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 |
23654
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
144 def Test_append() |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
145 new |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
146 setline(1, range(3)) |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
147 var res1: number = append(1, 'one') |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
148 assert_equal(0, res1) |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
149 var res2: bool = append(3, 'two') |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
150 assert_equal(false, res2) |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
151 assert_equal(['0', 'one', '1', 'two', '2'], getline(1, 6)) |
24258
8b4159943d9a
patch 8.2.2670: Vim9: error for append(0, text)
Bram Moolenaar <Bram@vim.org>
parents:
24254
diff
changeset
|
152 |
8b4159943d9a
patch 8.2.2670: Vim9: error for append(0, text)
Bram Moolenaar <Bram@vim.org>
parents:
24254
diff
changeset
|
153 append(0, 'zero') |
8b4159943d9a
patch 8.2.2670: Vim9: error for append(0, text)
Bram Moolenaar <Bram@vim.org>
parents:
24254
diff
changeset
|
154 assert_equal('zero', getline(1)) |
8b4159943d9a
patch 8.2.2670: Vim9: error for append(0, text)
Bram Moolenaar <Bram@vim.org>
parents:
24254
diff
changeset
|
155 bwipe! |
23654
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
156 enddef |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
157 |
24246
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
158 def Test_balloon_show() |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
159 CheckGui |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
160 CheckFeature balloon_eval |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
161 |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
162 assert_fails('balloon_show(true)', 'E1174:') |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
163 enddef |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
164 |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
165 def Test_balloon_split() |
24248
883d7ceffd97
patch 8.2.2665: test failures
Bram Moolenaar <Bram@vim.org>
parents:
24246
diff
changeset
|
166 CheckFeature balloon_eval_term |
24246
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
167 |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
168 assert_fails('balloon_split(true)', 'E1174:') |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
169 enddef |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
170 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
171 def Test_browse() |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
172 CheckFeature browse |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
173 |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
174 var lines =<< trim END |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
175 browse(1, 2, 3, 4) |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
176 END |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
177 CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 2') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
178 lines =<< trim END |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
179 browse(1, 'title', 3, 4) |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
180 END |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
181 CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 3') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
182 lines =<< trim END |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
183 browse(1, 'title', 'dir', 4) |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
184 END |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
185 CheckDefExecAndScriptFailure(lines, 'E1174: String required for argument 4') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
186 enddef |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
187 |
24246
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
188 def Test_bufexists() |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
189 assert_fails('bufexists(true)', 'E1174') |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
190 enddef |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
191 |
23654
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
192 def Test_buflisted() |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
193 var res: bool = buflisted('asdf') |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
194 assert_equal(false, res) |
24246
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
195 assert_fails('buflisted(true)', 'E1174') |
23654
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
196 enddef |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
197 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 def Test_bufname() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 split SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 bufname('%')->assert_equal('SomeFile') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 edit OtherFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 bufname('#')->assert_equal('SomeFile') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 close |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 def Test_bufnr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 var buf = bufnr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 bufnr('%')->assert_equal(buf) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 buf = bufnr('Xdummy', true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 buf->assert_notequal(-1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 exe 'bwipe! ' .. buf |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 def Test_bufwinid() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 var origwin = win_getid() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 below split SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 var SomeFileID = win_getid() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 below split OtherFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 below split SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 bufwinid('SomeFile')->assert_equal(SomeFileID) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 win_gotoid(origwin) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 only |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 bwipe SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 bwipe OtherFile |
24246
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
227 |
35603c7991d7
patch 8.2.2664: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24222
diff
changeset
|
228 assert_fails('bufwinid(true)', 'E1138') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 def Test_call_call() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 var l = [3, 2, 1] |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 call('reverse', [l]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 l->assert_equal([1, 2, 3]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 |
24250
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
237 def Test_ch_logfile() |
24349
21c72f782ae1
patch 8.2.2715: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
24258
diff
changeset
|
238 if !has('channel') |
21c72f782ae1
patch 8.2.2715: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
24258
diff
changeset
|
239 CheckFeature channel |
21c72f782ae1
patch 8.2.2715: Vim9: tests fail without the channel feature
Bram Moolenaar <Bram@vim.org>
parents:
24258
diff
changeset
|
240 endif |
24250
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
241 assert_fails('ch_logfile(true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
242 assert_fails('ch_logfile("foo", true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
243 enddef |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
244 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 def Test_char2nr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 char2nr('あ', true)->assert_equal(12354) |
24250
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
247 |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
248 assert_fails('char2nr(true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
249 enddef |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
250 |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
251 def Test_charclass() |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
252 assert_fails('charclass(true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
253 enddef |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
254 |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
255 def Test_chdir() |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
256 assert_fails('chdir(true)', 'E1174') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 def Test_col() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 setline(1, 'asdf') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 col([1, '$'])->assert_equal(5) |
24250
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
263 |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
264 assert_fails('col(true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
265 enddef |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
266 |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
267 def Test_confirm() |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
268 if !has('dialog_con') && !has('dialog_gui') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
269 CheckFeature dialog_con |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
270 endif |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
271 |
24254
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
272 assert_fails('confirm(true)', 'E1174') |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
273 assert_fails('confirm("yes", true)', 'E1174') |
0868ac82ef18
patch 8.2.2668: Vim9: omitting "call" for "confirm()" does not give an error
Bram Moolenaar <Bram@vim.org>
parents:
24250
diff
changeset
|
274 assert_fails('confirm("yes", "maybe", 2, true)', 'E1174') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 def Test_copy_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 var l = copy([1, 2, 3]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 res->assert_equal(6) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 var dl = deepcopy([1, 2, 3]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 for n in dl |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 res->assert_equal(6) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 dl = deepcopy([1, 2, 3], true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 def Test_count() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 count('ABC ABC ABC', 'b', true)->assert_equal(3) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 count('ABC ABC ABC', 'b', false)->assert_equal(0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 |
23276
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
300 def Test_cursor() |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
301 new |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
302 setline(1, range(4)) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
303 cursor(2, 1) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
304 assert_equal(2, getcurpos()[1]) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
305 cursor('$', 1) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
306 assert_equal(4, getcurpos()[1]) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
307 |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
308 var lines =<< trim END |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
309 cursor('2', 1) |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
310 END |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
311 CheckDefExecAndScriptFailure(lines, 'E475:') |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
312 enddef |
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23175
diff
changeset
|
313 |
23654
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
314 def Test_delete() |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
315 var res: bool = delete('doesnotexist') |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
316 assert_equal(true, res) |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
317 enddef |
1974c5122506
patch 8.2.2369: Vim9: functions return true/false but can't be used as bool
Bram Moolenaar <Bram@vim.org>
parents:
23646
diff
changeset
|
318 |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
319 def Test_executable() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
320 assert_false(executable("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
321 assert_false(executable(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
322 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
323 CheckDefExecFailure(['echo executable(123)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
324 CheckDefExecFailure(['echo executable(true)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
325 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
326 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
327 def Test_exepath() |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
328 CheckDefExecFailure(['echo exepath(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
329 CheckDefExecFailure(['echo exepath(v:null)'], 'E1174:') |
24222
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24210
diff
changeset
|
330 CheckDefExecFailure(['echo exepath("")'], 'E1175:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
331 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
332 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 def Test_expand() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 split SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 expand('%', true, true)->assert_equal(['SomeFile']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 close |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 |
24584
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
339 def Test_expandcmd() |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
340 $FOO = "blue" |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
341 assert_equal("blue sky", expandcmd("`=$FOO .. ' sky'`")) |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
342 |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
343 assert_equal("yes", expandcmd("`={a: 'yes'}['a']`")) |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
344 enddef |
abc4793f48a3
patch 8.2.2831: Vim9: expandcmd() not tested
Bram Moolenaar <Bram@vim.org>
parents:
24484
diff
changeset
|
345 |
22766
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
346 def Test_extend_arg_types() |
23800
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
347 g:number_one = 1 |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
348 g:string_keep = 'keep' |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
349 var lines =<< trim END |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
350 assert_equal([1, 2, 3], extend([1, 2], [3])) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
351 assert_equal([3, 1, 2], extend([1, 2], [3], 0)) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
352 assert_equal([1, 3, 2], extend([1, 2], [3], 1)) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
353 assert_equal([1, 3, 2], extend([1, 2], [3], g:number_one)) |
22766
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
354 |
23800
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
355 assert_equal({a: 1, b: 2, c: 3}, extend({a: 1, b: 2}, {c: 3})) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
356 assert_equal({a: 1, b: 4}, extend({a: 1, b: 2}, {b: 4})) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
357 assert_equal({a: 1, b: 2}, extend({a: 1, b: 2}, {b: 4}, 'keep')) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
358 assert_equal({a: 1, b: 2}, extend({a: 1, b: 2}, {b: 4}, g:string_keep)) |
22898
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
359 |
23800
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
360 var res: list<dict<any>> |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
361 extend(res, mapnew([1, 2], (_, v) => ({}))) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
362 assert_equal([{}, {}], res) |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
363 END |
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
364 CheckDefAndScriptSuccess(lines) |
22766
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
365 |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
366 CheckDefFailure(['extend("a", 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got string') |
22766
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
367 CheckDefFailure(['extend([1, 2], 3)'], 'E1013: Argument 2: type mismatch, expected list<number> but got number') |
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
368 CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>') |
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
369 CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') |
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
370 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
371 CheckDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict<number> but got number') |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
372 CheckDefFailure(['extend({a: 1}, {b: "x"})'], 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string>') |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
373 CheckDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number') |
23640
8dcb2255ff9a
patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
23604
diff
changeset
|
374 |
8dcb2255ff9a
patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents:
23604
diff
changeset
|
375 CheckDefFailure(['extend([1], ["b"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>') |
23691
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23654
diff
changeset
|
376 CheckDefExecFailure(['extend([1], ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<any>') |
22766
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
377 enddef |
a7082e865ffd
patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
378 |
23588
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
379 def Test_extendnew() |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
380 assert_equal([1, 2, 'a'], extendnew([1, 2], ['a'])) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
381 assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'})) |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
382 |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
383 CheckDefFailure(['extendnew({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict<number> but got number') |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
384 CheckDefFailure(['extendnew({a: 1}, [42])'], 'E1013: Argument 2: type mismatch, expected dict<number> but got list<number>') |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
385 CheckDefFailure(['extendnew([1, 2], "x")'], 'E1013: Argument 2: type mismatch, expected list<number> but got string') |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
386 CheckDefFailure(['extendnew([1, 2], {x: 1})'], 'E1013: Argument 2: type mismatch, expected list<number> but got dict<number>') |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
387 enddef |
510088f8c66f
patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
388 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 def Test_extend_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 var l = extend([1, 2], [3]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 res->assert_equal(6) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
398 func g:ExtendDict(d) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
399 call extend(a:d, #{xx: 'x'}) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
400 endfunc |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
401 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
402 def Test_extend_dict_item_type() |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
403 var lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
404 var d: dict<number> = {a: 1} |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
405 extend(d, {b: 2}) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
406 END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
407 CheckDefAndScriptSuccess(lines) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
408 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
409 lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
410 var d: dict<number> = {a: 1} |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
411 extend(d, {b: 'x'}) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
412 END |
23800
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
413 CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string>', 2) |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
414 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
415 lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
416 var d: dict<number> = {a: 1} |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
417 g:ExtendDict(d) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
418 END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
419 CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
420 CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
421 enddef |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
422 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
423 func g:ExtendList(l) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
424 call extend(a:l, ['x']) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
425 endfunc |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
426 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
427 def Test_extend_list_item_type() |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
428 var lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
429 var l: list<number> = [1] |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
430 extend(l, [2]) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
431 END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
432 CheckDefAndScriptSuccess(lines) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
433 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
434 lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
435 var l: list<number> = [1] |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
436 extend(l, ['x']) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
437 END |
23800
57f0e3fd7c05
patch 8.2.2441: Vim9: extend() does not give an error for a type mismatch
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
438 CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 2) |
23458
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
439 |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
440 lines =<< trim END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
441 var l: list<number> = [1] |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
442 g:ExtendList(l) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
443 END |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
444 CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
445 CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1) |
d2b1269c2c68
patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
446 enddef |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 |
24118
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
448 def Test_extend_with_error_function() |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
449 var lines =<< trim END |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
450 vim9script |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
451 def F() |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
452 { |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
453 var m = 10 |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
454 } |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
455 echo m |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
456 enddef |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
457 |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
458 def Test() |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
459 var d: dict<any> = {} |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
460 d->extend({A: 10, Func: function('F', [])}) |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
461 enddef |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
462 |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
463 Test() |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
464 END |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
465 CheckScriptFailure(lines, 'E1001: Variable not found: m') |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
466 enddef |
1027495445bc
patch 8.2.2600: Vim9: crash when putting an unknown type in a dictionary
Bram Moolenaar <Bram@vim.org>
parents:
24083
diff
changeset
|
467 |
23592
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
468 def Test_job_info_return_type() |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
469 if has('job') |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
470 job_start(&shell) |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
471 var jobs = job_info() |
23594
d3e064f54890
patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23592
diff
changeset
|
472 assert_equal('list<job>', typename(jobs)) |
d3e064f54890
patch 8.2.2339: cannot get the type of a value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23592
diff
changeset
|
473 assert_equal('dict<any>', typename(job_info(jobs[0]))) |
23592
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
474 job_stop(jobs[0]) |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
475 endif |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
476 enddef |
2322b643e329
patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents:
23588
diff
changeset
|
477 |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
478 def Test_filereadable() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
479 assert_false(filereadable("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
480 assert_false(filereadable(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
481 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
482 CheckDefExecFailure(['echo filereadable(123)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
483 CheckDefExecFailure(['echo filereadable(true)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
484 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
485 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
486 def Test_filewritable() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
487 assert_false(filewritable("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
488 assert_false(filewritable(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
489 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
490 CheckDefExecFailure(['echo filewritable(123)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
491 CheckDefExecFailure(['echo filewritable(true)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
492 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
493 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
494 def Test_finddir() |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
495 CheckDefExecFailure(['echo finddir(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
496 CheckDefExecFailure(['echo finddir(v:null)'], 'E1174:') |
24222
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24210
diff
changeset
|
497 CheckDefExecFailure(['echo finddir("")'], 'E1175:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
498 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
499 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
500 def Test_findfile() |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
501 CheckDefExecFailure(['echo findfile(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
502 CheckDefExecFailure(['echo findfile(v:null)'], 'E1174:') |
24222
a2e6029d354e
patch 8.2.2652: Vim9: can use command modifier without an effect
Bram Moolenaar <Bram@vim.org>
parents:
24210
diff
changeset
|
503 CheckDefExecFailure(['echo findfile("")'], 'E1175:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
504 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
505 |
23816
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
506 def Test_flattennew() |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
507 var lines =<< trim END |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
508 var l = [1, [2, [3, 4]], 5] |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
509 call assert_equal([1, 2, 3, 4, 5], flattennew(l)) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
510 call assert_equal([1, [2, [3, 4]], 5], l) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
511 |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
512 call assert_equal([1, 2, [3, 4], 5], flattennew(l, 1)) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
513 call assert_equal([1, [2, [3, 4]], 5], l) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
514 END |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
515 CheckDefAndScriptSuccess(lines) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
516 |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
517 lines =<< trim END |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
518 echo flatten([1, 2, 3]) |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
519 END |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
520 CheckDefAndScriptFailure(lines, 'E1158:') |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
521 enddef |
525c9e218c69
patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents:
23804
diff
changeset
|
522 |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
523 def Test_fnamemodify() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
524 CheckDefSuccess(['echo fnamemodify(test_null_string(), ":p")']) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
525 CheckDefSuccess(['echo fnamemodify("", ":p")']) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
526 CheckDefSuccess(['echo fnamemodify("file", test_null_string())']) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
527 CheckDefSuccess(['echo fnamemodify("file", "")']) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
528 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
529 CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E1174: String required for argument 1') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
530 CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E1174: String required for argument 1') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
531 CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E1174: String required for argument 2') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
532 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
533 |
23827
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23816
diff
changeset
|
534 def Wrong_dict_key_type(items: list<number>): list<number> |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23816
diff
changeset
|
535 return filter(items, (_, val) => get({[val]: 1}, 'x')) |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23816
diff
changeset
|
536 enddef |
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23816
diff
changeset
|
537 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 def Test_filter_wrong_dict_key_type() |
23827
7e0d8f1cae7d
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
23816
diff
changeset
|
539 assert_fails('Wrong_dict_key_type([1, v:null, 3])', 'E1013:') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 def Test_filter_return_type() |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24349
diff
changeset
|
543 var l = filter([1, 2, 3], (_, _) => 1) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 res->assert_equal(6) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 |
23350
9b86957ddd95
patch 8.2.2218: Vim9: failure if passing more args to lambda than expected
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
551 def Test_filter_missing_argument() |
9b86957ddd95
patch 8.2.2218: Vim9: failure if passing more args to lambda than expected
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
552 var dict = {aa: [1], ab: [2], ac: [3], de: [4]} |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24349
diff
changeset
|
553 var res = dict->filter((k, _) => k =~ 'a' && k !~ 'b') |
23350
9b86957ddd95
patch 8.2.2218: Vim9: failure if passing more args to lambda than expected
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
554 res->assert_equal({aa: [1], ac: [3]}) |
9b86957ddd95
patch 8.2.2218: Vim9: failure if passing more args to lambda than expected
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
555 enddef |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 |
24699
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
557 def Test_fullcommand() |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
558 assert_equal('next', fullcommand('n')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
559 assert_equal('noremap', fullcommand('no')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
560 assert_equal('noremap', fullcommand('nor')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
561 assert_equal('normal', fullcommand('norm')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
562 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
563 assert_equal('', fullcommand('k')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
564 assert_equal('keepmarks', fullcommand('ke')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
565 assert_equal('keepmarks', fullcommand('kee')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
566 assert_equal('keepmarks', fullcommand('keep')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
567 assert_equal('keepjumps', fullcommand('keepj')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
568 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
569 assert_equal('dlist', fullcommand('dl')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
570 assert_equal('', fullcommand('dp')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
571 assert_equal('delete', fullcommand('del')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
572 assert_equal('', fullcommand('dell')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
573 assert_equal('', fullcommand('delp')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
574 |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
575 assert_equal('srewind', fullcommand('sre')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
576 assert_equal('scriptnames', fullcommand('scr')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
577 assert_equal('', fullcommand('scg')) |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
578 enddef |
b19c8150ee9d
patch 8.2.2888: Vim9: "k" command recognized in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
579 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 def Test_garbagecollect() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 garbagecollect(true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 def Test_getbufinfo() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 var bufinfo = getbufinfo(bufnr()) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 getbufinfo('%')->assert_equal(bufinfo) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 edit Xtestfile1 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 hide edit Xtestfile2 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 hide enew |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
591 getbufinfo({bufloaded: true, buflisted: true, bufmodified: false}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 ->len()->assert_equal(3) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 bwipe Xtestfile1 Xtestfile2 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 def Test_getbufline() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 e SomeFile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 var buf = bufnr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 e # |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 var lines = ['aaa', 'bbb', 'ccc'] |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 setbufline(buf, 1, lines) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 getbufline('#', 1, '$')->assert_equal(lines) |
22679
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22661
diff
changeset
|
603 getbufline(-1, '$', '$')->assert_equal([]) |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22661
diff
changeset
|
604 getbufline(-1, 1, '$')->assert_equal([]) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 bwipe! |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 def Test_getchangelist() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 setline(1, 'some text') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 var changelist = bufnr()->getchangelist() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 getchangelist('%')->assert_equal(changelist) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 bwipe! |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 def Test_getchar() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 while getchar(0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 endwhile |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 getchar(true)->assert_equal(0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 |
24083
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
623 def Test_getenv() |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
624 if getenv('does-not_exist') == '' |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
625 assert_report('getenv() should return null') |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
626 endif |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
627 if getenv('does-not_exist') == null |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
628 else |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
629 assert_report('getenv() should return null') |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
630 endif |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
631 $SOMEENVVAR = 'some' |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
632 assert_equal('some', getenv('SOMEENVVAR')) |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
633 unlet $SOMEENVVAR |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
634 enddef |
1765b5b0f08d
patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents:
23990
diff
changeset
|
635 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 def Test_getcompletion() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 set wildignore=*.vim,*~ |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 var l = getcompletion('run', 'file', true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 l->assert_equal([]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 set wildignore& |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 def Test_getloclist_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 var l = getloclist(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 l->assert_equal([]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
647 var d = getloclist(1, {items: 0}) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
648 d->assert_equal({items: []}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
651 def Test_getfperm() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
652 assert_equal('', getfperm("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
653 assert_equal('', getfperm(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
654 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
655 CheckDefExecFailure(['echo getfperm(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
656 CheckDefExecFailure(['echo getfperm(v:null)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
657 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
658 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
659 def Test_getfsize() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
660 assert_equal(-1, getfsize("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
661 assert_equal(-1, getfsize(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
662 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
663 CheckDefExecFailure(['echo getfsize(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
664 CheckDefExecFailure(['echo getfsize(v:null)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
665 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
666 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
667 def Test_getftime() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
668 assert_equal(-1, getftime("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
669 assert_equal(-1, getftime(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
670 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
671 CheckDefExecFailure(['echo getftime(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
672 CheckDefExecFailure(['echo getftime(v:null)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
673 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
674 |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
675 def Test_getftype() |
23175
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
676 assert_equal('', getftype("")) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
677 assert_equal('', getftype(test_null_string())) |
d7294a6220ac
patch 8.2.2133: Vim9: checking for a non-empty string is too strict
Bram Moolenaar <Bram@vim.org>
parents:
23142
diff
changeset
|
678 |
24210
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
679 CheckDefExecFailure(['echo getftype(true)'], 'E1174:') |
083f07f99e20
patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents:
24118
diff
changeset
|
680 CheckDefExecFailure(['echo getftype(v:null)'], 'E1174:') |
23142
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
681 enddef |
5f08d4a42898
patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents:
23104
diff
changeset
|
682 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 def Test_getqflist_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 var l = getqflist() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 l->assert_equal([]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
687 var d = getqflist({items: 0}) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
688 d->assert_equal({items: []}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 def Test_getreg() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 var lines = ['aaa', 'bbb', 'ccc'] |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 setreg('a', lines) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 getreg('a', true, true)->assert_equal(lines) |
23909
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
695 assert_fails('getreg("ab")', 'E1162:') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 def Test_getreg_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 var s1: string = getreg('"') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 var s2: string = getreg('"', 1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 var s3: list<string> = getreg('"', 1, 1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 |
23909
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
704 def Test_getreginfo() |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
705 var text = 'abc' |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
706 setreg('a', text) |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
707 getreginfo('a')->assert_equal({regcontents: [text], regtype: 'v', isunnamed: false}) |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
708 assert_fails('getreginfo("ab")', 'E1162:') |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
709 enddef |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
710 |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
711 def Test_getregtype() |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
712 var lines = ['aaa', 'bbb', 'ccc'] |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
713 setreg('a', lines) |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
714 getregtype('a')->assert_equal('V') |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
715 assert_fails('getregtype("ab")', 'E1162:') |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
716 enddef |
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
717 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 def Test_glob() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 glob('runtest.vim', true, true, true)->assert_equal(['runtest.vim']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 def Test_globpath() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 globpath('.', 'runtest.vim', true, true, true)->assert_equal(['./runtest.vim']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 def Test_has() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 has('eval', true)->assert_equal(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 def Test_hasmapto() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 hasmapto('foobar', 'i', true)->assert_equal(0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 iabbrev foo foobar |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 hasmapto('foobar', 'i', true)->assert_equal(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 iunabbrev foo |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 def Test_index() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 |
22898
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
741 let s:number_one = 1 |
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
742 let s:number_two = 2 |
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
743 let s:string_keep = 'keep' |
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
744 |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
745 def Test_insert() |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 var l = insert([2, 1], 3) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 res->assert_equal(6) |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
752 |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
753 var m: any = [] |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
754 insert(m, 4) |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
755 call assert_equal([4], m) |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
756 extend(m, [6], 0) |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
757 call assert_equal([6, 4], m) |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
758 |
24484
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
759 var lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
760 insert(test_null_list(), 123) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
761 END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
762 CheckDefExecAndScriptFailure(lines, 'E1130:', 1) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
763 |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
764 lines =<< trim END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
765 insert(test_null_blob(), 123) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
766 END |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
767 CheckDefExecAndScriptFailure(lines, 'E1131:', 1) |
bc1a533148d7
patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents:
24482
diff
changeset
|
768 |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
769 assert_equal([1, 2, 3], insert([2, 3], 1)) |
22898
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
770 assert_equal([1, 2, 3], insert([2, 3], s:number_one)) |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
771 assert_equal([1, 2, 3], insert([1, 2], 3, 2)) |
22898
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
772 assert_equal([1, 2, 3], insert([1, 2], 3, s:number_two)) |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
773 assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a')) |
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
774 assert_equal(0z1234, insert(0z34, 0x12)) |
22898
a8bccb0634bc
patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents:
22766
diff
changeset
|
775 |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24659
diff
changeset
|
776 CheckDefFailure(['insert("a", 1)'], 'E1013: Argument 1: type mismatch, expected list<any> but got string', 1) |
22661
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
777 CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string', 1) |
c6b17787a38f
patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents:
22655
diff
changeset
|
778 CheckDefFailure(['insert([2, 3], 1, "x")'], 'E1013: Argument 3: type mismatch, expected number but got string', 1) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 def Test_keys_return_type() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
782 const var: list<string> = {a: 1, b: 2}->keys() |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 var->assert_equal(['a', 'b']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 |
24250
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
786 def Test_line() |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
787 assert_fails('line(true)', 'E1174') |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
788 enddef |
01b274c3f69b
patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
789 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 def Test_list2str_str2list_utf8() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 var s = "\u3042\u3044" |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 var l = [0x3042, 0x3044] |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 str2list(s, true)->assert_equal(l) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 list2str(l, true)->assert_equal(s) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 def SID(): number |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 return expand('<SID>') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 ->matchstr('<SNR>\zs\d\+\ze_$') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 ->str2nr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 |
23646
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
803 def Test_map_function_arg() |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
804 var lines =<< trim END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
805 def MapOne(i: number, v: string): string |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
806 return i .. ':' .. v |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
807 enddef |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
808 var l = ['a', 'b', 'c'] |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
809 map(l, MapOne) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
810 assert_equal(['0:a', '1:b', '2:c'], l) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
811 END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
812 CheckDefAndScriptSuccess(lines) |
24808
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
813 |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
814 lines =<< trim END |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
815 range(3)->map((a, b, c) => a + b + c) |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
816 END |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
817 CheckDefExecAndScriptFailure(lines, 'E1190: One argument too few') |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
818 lines =<< trim END |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
819 range(3)->map((a, b, c, d) => a + b + c + d) |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
820 END |
0bc60e26a2b5
patch 8.2.2942: Vim9: error when calling function with too few arguments
Bram Moolenaar <Bram@vim.org>
parents:
24699
diff
changeset
|
821 CheckDefExecAndScriptFailure(lines, 'E1190: 2 arguments too few') |
23646
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
822 enddef |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
823 |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
824 def Test_map_item_type() |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
825 var lines =<< trim END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
826 var l = ['a', 'b', 'c'] |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
827 map(l, (k, v) => k .. '/' .. v ) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
828 assert_equal(['0/a', '1/b', '2/c'], l) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
829 END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
830 CheckDefAndScriptSuccess(lines) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
831 |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
832 lines =<< trim END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
833 var l: list<number> = [0] |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
834 echo map(l, (_, v) => []) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
835 END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
836 CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<unknown>', 2) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
837 |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
838 lines =<< trim END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
839 var l: list<number> = range(2) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
840 echo map(l, (_, v) => []) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
841 END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
842 CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<unknown>', 2) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
843 |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
844 lines =<< trim END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
845 var d: dict<number> = {key: 0} |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
846 echo map(d, (_, v) => []) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
847 END |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
848 CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<unknown>', 2) |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
849 enddef |
5d77a7587927
patch 8.2.2365: Vim9: no check for map() changing item type at script level
Bram Moolenaar <Bram@vim.org>
parents:
23640
diff
changeset
|
850 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 def Test_maparg() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 var lnum = str2nr(expand('<sflnum>')) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 map foo bar |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
854 maparg('foo', '', false, true)->assert_equal({ |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 lnum: lnum + 1, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 script: 0, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 mode: ' ', |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 silent: 0, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 noremap: 0, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 lhs: 'foo', |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 lhsraw: 'foo', |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 nowait: 0, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 expr: 0, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 sid: SID(), |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 rhs: 'bar', |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 buffer: 0}) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 unmap foo |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 def Test_mapcheck() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 iabbrev foo foobar |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 mapcheck('foo', 'i', true)->assert_equal('foobar') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 iunabbrev foo |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 def Test_maparg_mapset() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 nnoremap <F3> :echo "hit F3"<CR> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 var mapsave = maparg('<F3>', 'n', false, true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 mapset('n', false, mapsave) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 nunmap <F3> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 |
23990
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
884 def Test_map_failure() |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
885 CheckFeature job |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
886 |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
887 var lines =<< trim END |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
888 vim9script |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
889 writefile([], 'Xtmpfile') |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
890 silent e Xtmpfile |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
891 var d = {[bufnr('%')]: {a: 0}} |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
892 au BufReadPost * Func() |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
893 def Func() |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
894 if d->has_key('') |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
895 endif |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
896 eval d[expand('<abuf>')]->mapnew((_, v: dict<job>) => 0) |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
897 enddef |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
898 e |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
899 END |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
900 CheckScriptFailure(lines, 'E1013:') |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
901 au! BufReadPost |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
902 delete('Xtmpfile') |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
903 enddef |
06da0685077b
patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents:
23909
diff
changeset
|
904 |
23705
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
905 def Test_max() |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
906 g:flag = true |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
907 var l1: list<number> = g:flag |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
908 ? [1, max([2, 3])] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
909 : [4, 5] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
910 assert_equal([1, 3], l1) |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
911 |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
912 g:flag = false |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
913 var l2: list<number> = g:flag |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
914 ? [1, max([2, 3])] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
915 : [4, 5] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
916 assert_equal([4, 5], l2) |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
917 enddef |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
918 |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
919 def Test_min() |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
920 g:flag = true |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
921 var l1: list<number> = g:flag |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
922 ? [1, min([2, 3])] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
923 : [4, 5] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
924 assert_equal([1, 2], l1) |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
925 |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
926 g:flag = false |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
927 var l2: list<number> = g:flag |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
928 ? [1, min([2, 3])] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
929 : [4, 5] |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
930 assert_equal([4, 5], l2) |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
931 enddef |
9092d2a4422a
patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
932 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 def Test_nr2char() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 nr2char(97, true)->assert_equal('a') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 def Test_readdir() |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
938 eval expand('sautest')->readdir((e) => e[0] !=# '.') |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
939 eval expand('sautest')->readdirex((e) => e.name[0] !=# '.') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 |
23602
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
942 def Test_readblob() |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
943 var blob = 0z12341234 |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
944 writefile(blob, 'Xreadblob') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
945 var read: blob = readblob('Xreadblob') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
946 assert_equal(blob, read) |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
947 |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
948 var lines =<< trim END |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
949 var read: list<string> = readblob('Xreadblob') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
950 END |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
951 CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<string> but got blob', 1) |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
952 delete('Xreadblob') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
953 enddef |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
954 |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
955 def Test_readfile() |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
956 var text = ['aaa', 'bbb', 'ccc'] |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
957 writefile(text, 'Xreadfile') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
958 var read: list<string> = readfile('Xreadfile') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
959 assert_equal(text, read) |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
960 |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
961 var lines =<< trim END |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
962 var read: dict<string> = readfile('Xreadfile') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
963 END |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
964 CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1) |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
965 delete('Xreadfile') |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
966 enddef |
7b3317e959e3
patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents:
23596
diff
changeset
|
967 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 def Test_remove_return_type() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
969 var l = remove({one: [1, 2], two: [3, 4]}, 'one') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 res->assert_equal(3) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 def Test_reverse_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 var l = reverse([1, 2, 3]) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 var res = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 for n in l |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 res += n |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 endfor |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 res->assert_equal(6) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 def Test_search() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 setline(1, ['foo', 'bar']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 var val = 0 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 # skip expr returns boolean |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
991 search('bar', 'W', 0, 0, () => val == 1)->assert_equal(2) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 :1 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
993 search('bar', 'W', 0, 0, () => val == 0)->assert_equal(0) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 # skip expr returns number, only 0 and 1 are accepted |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 :1 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
996 search('bar', 'W', 0, 0, () => 0)->assert_equal(2) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 :1 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
998 search('bar', 'W', 0, 0, () => 1)->assert_equal(0) |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
999 assert_fails("search('bar', '', 0, 0, () => -1)", 'E1023:') |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
1000 assert_fails("search('bar', '', 0, 0, () => -1)", 'E1023:') |
24608
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1001 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1002 setline(1, "find this word") |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1003 normal gg |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1004 var col = 7 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1005 assert_equal(1, search('this', '', 0, 0, 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1006 normal 0 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1007 assert_equal([1, 6], searchpos('this', '', 0, 0, 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1008 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1009 col = 5 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1010 normal 0 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1011 assert_equal(0, search('this', '', 0, 0, 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1012 normal 0 |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1013 assert_equal([0, 0], searchpos('this', '', 0, 0, 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1014 bwipe! |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 def Test_searchcount() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 setline(1, "foo bar") |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 :/foo |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1021 searchcount({recompute: true}) |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1022 ->assert_equal({ |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 exact_match: 1, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 current: 1, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 total: 1, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 maxcount: 99, |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 incomplete: 0}) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 bwipe! |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1031 def Test_searchpair() |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1032 new |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1033 setline(1, "here { and } there") |
24608
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1034 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1035 normal f{ |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1036 var col = 15 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1037 assert_equal(1, searchpair('{', '', '}', '', 'col(".") > col')) |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1038 assert_equal(12, col('.')) |
24608
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1039 normal 0f{ |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1040 assert_equal([1, 12], searchpairpos('{', '', '}', '', 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1041 |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1042 col = 8 |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1043 normal 0f{ |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1044 assert_equal(0, searchpair('{', '', '}', '', 'col(".") > col')) |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1045 assert_equal(6, col('.')) |
24608
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1046 normal 0f{ |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1047 assert_equal([0, 0], searchpairpos('{', '', '}', '', 'col(".") > col')) |
cb031f421ece
patch 8.2.2843: Vim9: skip argument to searchpairpos() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24606
diff
changeset
|
1048 |
24637
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1049 var lines =<< trim END |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1050 vim9script |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1051 setline(1, '()') |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1052 normal gg |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1053 def Fail() |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1054 try |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1055 searchpairpos('(', '', ')', 'nW', '[0]->map("")') |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1056 catch |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1057 g:caught = 'yes' |
24637
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1058 endtry |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1059 enddef |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1060 Fail() |
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1061 END |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1062 CheckScriptSuccess(lines) |
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1063 assert_equal('yes', g:caught) |
24637
4a4f64cdc798
patch 8.2.2857: Vim9: exception in ISN_INSTR caught at wrong level
Bram Moolenaar <Bram@vim.org>
parents:
24608
diff
changeset
|
1064 |
24659
982516c8d692
patch 8.2.2868: Vim9: when executing compiled expression trylevel is changed
Bram Moolenaar <Bram@vim.org>
parents:
24637
diff
changeset
|
1065 unlet g:caught |
24606
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1066 bwipe! |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1067 enddef |
a4fda40e0bb9
patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents:
24584
diff
changeset
|
1068 |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1069 def Test_set_get_bufline() |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1070 # similar to Test_setbufline_getbufline() |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1071 var lines =<< trim END |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1072 new |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1073 var b = bufnr('%') |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1074 hide |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1075 assert_equal(0, setbufline(b, 1, ['foo', 'bar'])) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1076 assert_equal(['foo'], getbufline(b, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1077 assert_equal(['bar'], getbufline(b, '$')) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1078 assert_equal(['foo', 'bar'], getbufline(b, 1, 2)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1079 exe "bd!" b |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1080 assert_equal([], getbufline(b, 1, 2)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1081 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1082 split Xtest |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1083 setline(1, ['a', 'b', 'c']) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1084 b = bufnr('%') |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1085 wincmd w |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1086 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1087 assert_equal(1, setbufline(b, 5, 'x')) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1088 assert_equal(1, setbufline(b, 5, ['x'])) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1089 assert_equal(1, setbufline(b, 5, [])) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1090 assert_equal(1, setbufline(b, 5, test_null_list())) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1091 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1092 assert_equal(1, 'x'->setbufline(bufnr('$') + 1, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1093 assert_equal(1, ['x']->setbufline(bufnr('$') + 1, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1094 assert_equal(1, []->setbufline(bufnr('$') + 1, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1095 assert_equal(1, test_null_list()->setbufline(bufnr('$') + 1, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1096 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1097 assert_equal(['a', 'b', 'c'], getbufline(b, 1, '$')) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1098 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1099 assert_equal(0, setbufline(b, 4, ['d', 'e'])) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1100 assert_equal(['c'], b->getbufline(3)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1101 assert_equal(['d'], getbufline(b, 4)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1102 assert_equal(['e'], getbufline(b, 5)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1103 assert_equal([], getbufline(b, 6)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1104 assert_equal([], getbufline(b, 2, 1)) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1105 |
23875
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1106 if has('job') |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1107 setbufline(b, 2, [function('eval'), {key: 123}, string(test_null_job())]) |
23875
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1108 assert_equal(["function('eval')", |
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1109 "{'key': 123}", |
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1110 "no process"], |
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1111 getbufline(b, 2, 4)) |
54b583156d53
patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents:
23827
diff
changeset
|
1112 endif |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1113 |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1114 exe 'bwipe! ' .. b |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1115 END |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1116 CheckDefAndScriptSuccess(lines) |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1117 enddef |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23786
diff
changeset
|
1118 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 def Test_searchdecl() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 searchdecl('blah', true, true)->assert_equal(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 def Test_setbufvar() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 setbufvar(bufnr('%'), '&syntax', 'vim') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 &syntax->assert_equal('vim') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 setbufvar(bufnr('%'), '&ts', 16) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 &ts->assert_equal(16) |
23483
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1128 setbufvar(bufnr('%'), '&ai', true) |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1129 &ai->assert_equal(true) |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1130 setbufvar(bufnr('%'), '&ft', 'filetype') |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1131 &ft->assert_equal('filetype') |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1132 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 settabwinvar(1, 1, '&syntax', 'vam') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 &syntax->assert_equal('vam') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 settabwinvar(1, 1, '&ts', 15) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 &ts->assert_equal(15) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 setlocal ts=8 |
23485
198ad7ef2420
patch 8.2.2285: Vim9: cannot set an option to a false
Bram Moolenaar <Bram@vim.org>
parents:
23483
diff
changeset
|
1138 settabwinvar(1, 1, '&list', false) |
198ad7ef2420
patch 8.2.2285: Vim9: cannot set an option to a false
Bram Moolenaar <Bram@vim.org>
parents:
23483
diff
changeset
|
1139 &list->assert_equal(false) |
23483
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1140 settabwinvar(1, 1, '&list', true) |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1141 &list->assert_equal(true) |
ce7d6b461660
patch 8.2.2284: Vim9: cannot set an option to a boolean value
Bram Moolenaar <Bram@vim.org>
parents:
23458
diff
changeset
|
1142 setlocal list& |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 setbufvar('%', 'myvar', 123) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 getbufvar('%', 'myvar')->assert_equal(123) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 def Test_setloclist() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1149 var items = [{filename: '/tmp/file', lnum: 1, valid: true}] |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1150 var what = {items: items} |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 setqflist([], ' ', what) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 setloclist(0, [], ' ', what) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 def Test_setreg() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 setreg('a', ['aaa', 'bbb', 'ccc']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 var reginfo = getreginfo('a') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 setreg('a', reginfo) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 getreginfo('a')->assert_equal(reginfo) |
23909
5db7d275543c
patch 8.2.2497: no error when using more than one character for a register
Bram Moolenaar <Bram@vim.org>
parents:
23875
diff
changeset
|
1160 assert_fails('setreg("ab", 0)', 'E1162:') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 |
23604
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1163 def Test_slice() |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1164 assert_equal('12345', slice('012345', 1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1165 assert_equal('123', slice('012345', 1, 4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1166 assert_equal('1234', slice('012345', 1, -1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1167 assert_equal('1', slice('012345', 1, -4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1168 assert_equal('', slice('012345', 1, -5)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1169 assert_equal('', slice('012345', 1, -6)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1170 |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1171 assert_equal([1, 2, 3, 4, 5], slice(range(6), 1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1172 assert_equal([1, 2, 3], slice(range(6), 1, 4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1173 assert_equal([1, 2, 3, 4], slice(range(6), 1, -1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1174 assert_equal([1], slice(range(6), 1, -4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1175 assert_equal([], slice(range(6), 1, -5)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1176 assert_equal([], slice(range(6), 1, -6)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1177 |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1178 assert_equal(0z1122334455, slice(0z001122334455, 1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1179 assert_equal(0z112233, slice(0z001122334455, 1, 4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1180 assert_equal(0z11223344, slice(0z001122334455, 1, -1)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1181 assert_equal(0z11, slice(0z001122334455, 1, -4)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1182 assert_equal(0z, slice(0z001122334455, 1, -5)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1183 assert_equal(0z, slice(0z001122334455, 1, -6)) |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1184 enddef |
1816ea68c022
patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents:
23602
diff
changeset
|
1185 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 def Test_spellsuggest() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 if !has('spell') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 MissingFeature 'spell' |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 else |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 spellsuggest('marrch', 1, true)->assert_equal(['March']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 endif |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 def Test_sort_return_type() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 var res: list<number> |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 res = [1, 2, 3]->sort() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 def Test_sort_argument() |
23104
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1200 var lines =<< trim END |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1201 var res = ['b', 'a', 'c']->sort('i') |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1202 res->assert_equal(['a', 'b', 'c']) |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1203 |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1204 def Compare(a: number, b: number): number |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1205 return a - b |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1206 enddef |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1207 var l = [3, 6, 7, 1, 8, 2, 4, 5] |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1208 sort(l, Compare) |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1209 assert_equal([1, 2, 3, 4, 5, 6, 7, 8], l) |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1210 END |
1013a97d5dc0
patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
1211 CheckDefAndScriptSuccess(lines) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 def Test_split() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', '']) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 |
23804
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1218 def Run_str2float() |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1219 if !has('float') |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1220 MissingFeature 'float' |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1221 endif |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1222 str2float("1.00")->assert_equal(1.00) |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1223 str2float("2e-2")->assert_equal(0.02) |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1224 |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1225 CheckDefFailure(['echo str2float(123)'], 'E1013:') |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1226 CheckScriptFailure(['vim9script', 'echo str2float(123)'], 'E1024:') |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1227 endif |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1228 enddef |
007fa6365dfb
patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents:
23800
diff
changeset
|
1229 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 def Test_str2nr() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 str2nr("1'000'000", 10, true)->assert_equal(1000000) |
23786
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1232 |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1233 CheckDefFailure(['echo str2nr(123)'], 'E1013:') |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1234 CheckScriptFailure(['vim9script', 'echo str2nr(123)'], 'E1024:') |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1235 CheckDefFailure(['echo str2nr("123", "x")'], 'E1013:') |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1236 CheckScriptFailure(['vim9script', 'echo str2nr("123", "x")'], 'E1030:') |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1237 CheckDefFailure(['echo str2nr("123", 10, "x")'], 'E1013:') |
0512923e54e1
patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents:
23705
diff
changeset
|
1238 CheckScriptFailure(['vim9script', 'echo str2nr("123", 10, "x")'], 'E1135:') |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 def Test_strchars() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 strchars("A\u20dd", true)->assert_equal(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 def Test_submatch() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 var pat = 'A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)' |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23535
diff
changeset
|
1247 var Rep = () => range(10)->mapnew((_, v) => submatch(v, true))->string() |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 var actual = substitute('A123456789', pat, Rep, '') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 var expected = "[['A123456789'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]" |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 actual->assert_equal(expected) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1253 def Test_substitute() |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1254 var res = substitute('A1234', '\d', 'X', '') |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1255 assert_equal('AX234', res) |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1256 |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1257 if has('job') |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1258 assert_fails('"text"->substitute(".*", () => job_start(":"), "")', 'E908: using an invalid value as a String: job') |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1259 assert_fails('"text"->substitute(".*", () => job_start(":")->job_getchannel(), "")', 'E908: using an invalid value as a String: channel') |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1260 endif |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1261 enddef |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
24808
diff
changeset
|
1262 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1263 def Test_synID() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 setline(1, "text") |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 synID(1, 1, true)->assert_equal(0) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 bwipe! |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 def Test_term_gettty() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 if !has('terminal') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 MissingFeature 'terminal' |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 else |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 var buf = Run_shell_in_terminal({}) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 term_gettty(buf, true)->assert_notequal('') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 StopShellInTerminal(buf) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 endif |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 def Test_term_start() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 if !has('terminal') |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 MissingFeature 'terminal' |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 else |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 botright new |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 var winnr = winnr() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1286 term_start(&shell, {curwin: true}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1287 winnr()->assert_equal(winnr) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 bwipe! |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 endif |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 def Test_timer_paused() |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23404
diff
changeset
|
1293 var id = timer_start(50, () => 0) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 timer_pause(id, true) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 var info = timer_info(id) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 info[0]['paused']->assert_equal(1) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 timer_stop(id) |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 |
23596
9fa72351c18f
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents:
23594
diff
changeset
|
1300 def Test_win_execute() |
9fa72351c18f
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents:
23594
diff
changeset
|
1301 assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()')) |
9fa72351c18f
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents:
23594
diff
changeset
|
1302 assert_equal('', win_execute(342343, 'echo winnr()')) |
9fa72351c18f
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents:
23594
diff
changeset
|
1303 enddef |
9fa72351c18f
patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents:
23594
diff
changeset
|
1304 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 def Test_win_splitmove() |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 split |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
1307 win_splitmove(1, 2, {vertical: true, rightbelow: true}) |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 close |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 enddef |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 |
23404
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1311 def Test_winrestcmd() |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1312 split |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1313 var cmd = winrestcmd() |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1314 wincmd _ |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1315 exe cmd |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1316 assert_equal(cmd, winrestcmd()) |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1317 close |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1318 enddef |
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1319 |
23535
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1320 def Test_winsaveview() |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1321 var view: dict<number> = winsaveview() |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1322 |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1323 var lines =<< trim END |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1324 var view: list<number> = winsaveview() |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1325 END |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1326 CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<number> but got dict<number>', 1) |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1327 enddef |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1328 |
98185d3dd369
patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents:
23485
diff
changeset
|
1329 |
23404
a6b6bcc004f2
patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents:
23350
diff
changeset
|
1330 |
22655
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 |
eabe2c1444ea
patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |