annotate src/testdir/test_vim9_builtin.vim @ 24606:a4fda40e0bb9 v8.2.2842

patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled Commit: https://github.com/vim/vim/commit/f18332fb9e2e4208a97d800f096b02c6681780e7 Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 7 17:55:55 2021 +0200 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled Problem: Vim9: skip argument to searchpair() is not compiled. Solution: Add VAR_INSTR.
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 May 2021 18:00:04 +0200
parents abc4793f48a3
children cb031f421ece
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22679
diff changeset
366 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
367 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
368 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
369
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
370 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
371 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
372 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
373
8dcb2255ff9a patch 8.2.2362: Vim9: check of builtin function argument type is incomplete
Bram Moolenaar <Bram@vim.org>
parents: 23604
diff changeset
374 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
375 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
376 enddef
a7082e865ffd patch 8.2.1931: Vim9: arguments of extend() not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 22679
diff changeset
377
23588
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
378 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
379 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
380 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
381
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
382 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
383 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
384 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
385 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
386 enddef
510088f8c66f patch 8.2.2336: Vim9: not possible to extend dictionary with different type
Bram Moolenaar <Bram@vim.org>
parents: 23565
diff changeset
387
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 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
389 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
390 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
391 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
392 res += n
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 endfor
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 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
395 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396
23458
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
397 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
398 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
399 endfunc
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
400
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
401 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
402 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
403 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
404 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
405 END
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
406 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
407
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
408 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
409 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
410 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
411 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
412 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
413
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
414 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
415 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
416 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
417 END
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
418 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
419 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
420 enddef
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
421
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
422 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
423 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
424 endfunc
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
425
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
426 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
427 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
428 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
429 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
430 END
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
431 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
432
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
433 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
434 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
435 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
436 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
437 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
438
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
439 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
440 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
441 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
442 END
d2b1269c2c68 patch 8.2.2272: Vim9: extend() can violate the type of a variable
Bram Moolenaar <Bram@vim.org>
parents: 23428
diff changeset
443 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
444 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
445 enddef
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446
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
447 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
448 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
449 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
450 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
451 {
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 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
453 }
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 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
455 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
456
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 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
458 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
459 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
460 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
461
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 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
463 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
464 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
465 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
466
23592
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 endif
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
475 enddef
2322b643e329 patch 8.2.2338: Vim9: no error if using job_info() result wrongly
Bram Moolenaar <Bram@vim.org>
parents: 23588
diff changeset
476
23142
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
477 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
478 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
479 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
480
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
481 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
482 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
483 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
484
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
485 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
486 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
487 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
488
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
489 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
490 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
491 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
492
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
493 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
494 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
495 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
496 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
497 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
498
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
499 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
500 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
501 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
502 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
503 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
504
23816
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
505 def Test_flattennew()
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
506 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
507 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
508 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
509 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
510
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
511 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
512 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
513 END
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
514 CheckDefAndScriptSuccess(lines)
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
515
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
516 lines =<< trim END
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
517 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
518 END
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
519 CheckDefAndScriptFailure(lines, 'E1158:')
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
520 enddef
525c9e218c69 patch 8.2.2449: Vim9: flatten() always changes the list type
Bram Moolenaar <Bram@vim.org>
parents: 23804
diff changeset
521
23142
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
522 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
523 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
524 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
525 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
526 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
527
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
528 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
529 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
530 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
531 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
532
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
533 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
534 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
535 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
536
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 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
538 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
539 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 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
542 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
543 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
544 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
545 res += n
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 endfor
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 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
548 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549
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
550 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
551 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
552 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
553 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
554 enddef
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 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
557 garbagecollect(true)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 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
561 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
562 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
563
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 edit Xtestfile1
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 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
566 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
567 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
568 ->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
569 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
570 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 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
573 e SomeFile
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 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
575 e #
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576 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
577 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
578 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
579 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
580 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
581
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 bwipe!
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 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
586 new
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 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
588 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
589 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
590 bwipe!
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 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
594 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
595 endwhile
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 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
597 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598
24083
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
599 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
600 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
601 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
602 endif
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
603 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
604 else
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
605 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
606 endif
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
607 $SOMEENVVAR = 'some'
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
608 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
609 unlet $SOMEENVVAR
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
610 enddef
1765b5b0f08d patch 8.2.2583: Vim9: cannot compare result of getenv() with null
Bram Moolenaar <Bram@vim.org>
parents: 23990
diff changeset
611
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 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
613 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
614 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
615 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
616 set wildignore&
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 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
620 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
621 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
622
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
623 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
624 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
625 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626
23142
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
627 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
628 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
629 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
630
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
631 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
632 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
633 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
634
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
635 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
636 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
637 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
638
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
639 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
640 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
641 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
642
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
643 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
644 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
645 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
646
24210
083f07f99e20 patch 8.2.2646: Vim9: error for not using string doesn't mentionargument
Bram Moolenaar <Bram@vim.org>
parents: 24118
diff changeset
647 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
648 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
649 enddef
5f08d4a42898 patch 8.2.2117: some functions use any value as a string
Bram Moolenaar <Bram@vim.org>
parents: 23104
diff changeset
650
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_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
652 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
653 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
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 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
656 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
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
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 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
660 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
661 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
662
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
663 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
664 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
665 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 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
668 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
669 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
670 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
671 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
672 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 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
675 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
676 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
677 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
678 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679
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
680 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
681 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
682 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
683 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
684 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
685 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
686
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
687 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
688 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
689 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
690 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
691 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
692 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
693
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 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
695 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
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_globpath()
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 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
700 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 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
703 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
704 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 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
707 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
708 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
709 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
710 iunabbrev foo
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
712
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 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
714 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
715 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716
22898
a8bccb0634bc patch 8.2.1996: Vim9: invalid error for argument of extend()
Bram Moolenaar <Bram@vim.org>
parents: 22766
diff changeset
717 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
718 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
719 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
720
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
721 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
722 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
723 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
724 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
725 res += n
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 endfor
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 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
728
24484
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
729 var lines =<< trim END
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
730 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
731 END
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
732 CheckDefExecAndScriptFailure(lines, 'E1130:', 1)
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
733
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
734 lines =<< trim END
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
735 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
736 END
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
737 CheckDefExecAndScriptFailure(lines, 'E1131:', 1)
bc1a533148d7 patch 8.2.2782: Vim9: blob operations not fully tested
Bram Moolenaar <Bram@vim.org>
parents: 24482
diff changeset
738
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
739 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
740 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
741 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
742 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
743 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
744 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
745
22661
c6b17787a38f patch 8.2.1879: Vim9: argument types of insert() not checked when compiling
Bram Moolenaar <Bram@vim.org>
parents: 22655
diff changeset
746 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
747 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
748 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
749
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 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
751 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
752 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
753 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754
24250
01b274c3f69b patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24248
diff changeset
755 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
756 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
757 enddef
01b274c3f69b patch 8.2.2666: Vim9: not enough function arguments checked for string
Bram Moolenaar <Bram@vim.org>
parents: 24248
diff changeset
758
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 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
760 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
761 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
762 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
763 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
764 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766 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
767 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
768 ->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
769 ->str2nr()
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771
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
772 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
773 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
774 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
775 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
776 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
777 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
778 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
779 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
780 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
781 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
782 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
783
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
784 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
785 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
786 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
787 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
788 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
789 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
790 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
791
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
792 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
793 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
794 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
795 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
796 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
797
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
798 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
799 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
800 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
801 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
802 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
803
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 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 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
806 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
807 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
808 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
809 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
810
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
811 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
812 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
813 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
814 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
815 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
816 script: 0,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 mode: ' ',
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 silent: 0,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 noremap: 0,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 lhs: 'foo',
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 lhsraw: 'foo',
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 nowait: 0,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
823 expr: 0,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
824 sid: SID(),
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
825 rhs: 'bar',
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 buffer: 0})
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
827 unmap foo
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
829
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 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
831 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
832 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
833 iunabbrev foo
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
834 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 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
837 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
838 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
839 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
840
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
841 nunmap <F3>
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843
23990
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
844 def Test_map_failure()
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
845 CheckFeature job
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
846
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
847 var lines =<< trim END
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
848 vim9script
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
849 writefile([], 'Xtmpfile')
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
850 silent e Xtmpfile
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
851 var d = {[bufnr('%')]: {a: 0}}
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
852 au BufReadPost * Func()
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
853 def Func()
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
854 if d->has_key('')
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
855 endif
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
856 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
857 enddef
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
858 e
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
859 END
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
860 CheckScriptFailure(lines, 'E1013:')
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
861 au! BufReadPost
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
862 delete('Xtmpfile')
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
863 enddef
06da0685077b patch 8.2.2537: Vim9: crash when map() fails
Bram Moolenaar <Bram@vim.org>
parents: 23909
diff changeset
864
23705
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
865 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
866 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
867 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
868 ? [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
869 : [4, 5]
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
870 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
871
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
872 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
873 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
874 ? [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
875 : [4, 5]
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
876 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
877 enddef
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
878
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
879 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
880 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
881 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
882 ? [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
883 : [4, 5]
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
884 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
885
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
886 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
887 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
888 ? [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
889 : [4, 5]
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
890 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
891 enddef
9092d2a4422a patch 8.2.2394: Vim9: min() and max() return type is "any"
Bram Moolenaar <Bram@vim.org>
parents: 23691
diff changeset
892
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 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
894 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
895 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
897 def Test_readdir()
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23404
diff changeset
898 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
899 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
900 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901
23602
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
902 def Test_readblob()
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
903 var blob = 0z12341234
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
904 writefile(blob, 'Xreadblob')
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
905 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
906 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
907
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
908 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
909 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
910 END
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
911 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
912 delete('Xreadblob')
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
913 enddef
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
914
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
915 def Test_readfile()
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
916 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
917 writefile(text, 'Xreadfile')
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
918 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
919 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
920
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
921 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
922 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
923 END
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
924 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
925 delete('Xreadfile')
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
926 enddef
7b3317e959e3 patch 8.2.2343: Vim9: return type of readfile() is any
Bram Moolenaar <Bram@vim.org>
parents: 23596
diff changeset
927
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 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
929 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
930 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
931 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
932 res += n
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 endfor
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 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
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_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
938 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
939 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
940 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
941 res += n
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 endfor
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 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
944 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 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
947 new
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 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
949 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
950 # 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
951 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
952 :1
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23404
diff changeset
953 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
954 # 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
955 :1
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23404
diff changeset
956 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
957 :1
23428
5807e3958e38 patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents: 23404
diff changeset
958 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
959 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
960 assert_fails("search('bar', '', 0, 0, () => -1)", 'E1023:')
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
962
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963 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
964 new
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 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
966 :/foo
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
967 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
968 ->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
969 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
970 current: 1,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 total: 1,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972 maxcount: 99,
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 incomplete: 0})
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 bwipe!
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
24606
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
977 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
978 new
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
979 setline(1, "here { and } there")
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
980 normal f{
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
981 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
982 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
983 assert_equal(12, col('.'))
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
984 col = 8
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
985 normal 0f{
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
986 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
987 assert_equal(6, col('.'))
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
988 bwipe!
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
989 enddef
a4fda40e0bb9 patch 8.2.2842: Vim9: skip argument to searchpair() is not compiled
Bram Moolenaar <Bram@vim.org>
parents: 24584
diff changeset
990
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
991 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
992 # 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
993 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
994 new
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
995 var b = bufnr('%')
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
996 hide
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
997 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
998 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
999 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
1000 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
1001 exe "bd!" b
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1002 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
1003
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1004 split Xtest
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1005 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
1006 b = bufnr('%')
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1007 wincmd w
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1008
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1009 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
1010 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
1011 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
1012 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
1013
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1014 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
1015 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
1016 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
1017 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
1018
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1019 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
1020
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1021 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
1022 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
1023 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
1024 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
1025 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
1026 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
1027
23875
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23827
diff changeset
1028 if has('job')
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23827
diff changeset
1029 setbufline(b, 2, [function('eval'), {key: 123}, test_null_job()])
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23827
diff changeset
1030 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
1031 "{'key': 123}",
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23827
diff changeset
1032 "no process"],
54b583156d53 patch 8.2.2479: set/getbufline test fails without the job feature
Bram Moolenaar <Bram@vim.org>
parents: 23827
diff changeset
1033 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
1034 endif
23788
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1035
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1036 exe 'bwipe! ' .. b
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1037 END
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1038 CheckDefAndScriptSuccess(lines)
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1039 enddef
d12ef361d9de patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents: 23786
diff changeset
1040
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 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
1042 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
1043 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 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
1046 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
1047 &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
1048 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
1049 &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
1050 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
1051 &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
1052 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
1053 &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
1054
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 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
1056 &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
1057 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
1058 &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
1059 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
1060 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
1061 &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
1062 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
1063 &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
1064 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
1065
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066 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
1067 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
1068 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 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
1071 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
1072 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
1073 setqflist([], ' ', what)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 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
1075 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 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
1078 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
1079 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
1080 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
1081 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
1082 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
1083 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084
23604
1816ea68c022 patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents: 23602
diff changeset
1085 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
1086 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
1087 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
1088 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
1089 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
1090 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
1091 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
1092
1816ea68c022 patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents: 23602
diff changeset
1093 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
1094 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
1095 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
1096 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
1097 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
1098 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
1099
1816ea68c022 patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents: 23602
diff changeset
1100 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
1101 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
1102 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
1103 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
1104 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
1105 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
1106 enddef
1816ea68c022 patch 8.2.2344: using inclusive index for slice is not always desired
Bram Moolenaar <Bram@vim.org>
parents: 23602
diff changeset
1107
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 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
1109 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
1110 MissingFeature 'spell'
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1111 else
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 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
1113 endif
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1114 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 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
1117 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
1118 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
1119 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 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
1122 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
1123 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
1124 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
1125
1013a97d5dc0 patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1126 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
1127 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
1128 enddef
1013a97d5dc0 patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1129 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
1130 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
1131 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
1132 END
1013a97d5dc0 patch 8.2.2098: Vim9: function argument of sort() and map() not tested
Bram Moolenaar <Bram@vim.org>
parents: 23072
diff changeset
1133 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
1134 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 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
1137 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
1138 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139
23804
007fa6365dfb patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents: 23800
diff changeset
1140 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
1141 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
1142 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
1143 endif
007fa6365dfb patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents: 23800
diff changeset
1144 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
1145 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
1146
007fa6365dfb patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents: 23800
diff changeset
1147 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
1148 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
1149 endif
007fa6365dfb patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents: 23800
diff changeset
1150 enddef
007fa6365dfb patch 8.2.2443: Vim9: no compile time error for wrong str2float argument
Bram Moolenaar <Bram@vim.org>
parents: 23800
diff changeset
1151
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 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
1153 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
1154
0512923e54e1 patch 8.2.2434: Vim9: no error when compiling str2nr() with a number
Bram Moolenaar <Bram@vim.org>
parents: 23705
diff changeset
1155 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
1156 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
1157 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
1158 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
1159 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
1160 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
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
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 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
1164 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
1165 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 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
1168 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
1169 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
1170 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
1171 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
1172 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
1173 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 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
1176 new
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 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
1178 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
1179 bwipe!
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 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
1183 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
1184 MissingFeature 'terminal'
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 else
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 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
1187 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
1188 StopShellInTerminal(buf)
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 endif
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 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
1193 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
1194 MissingFeature 'terminal'
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 else
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 botright new
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 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
1198 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
1199 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
1200 bwipe!
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 endif
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 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
1205 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
1206 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
1207 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
1208 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
1209 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
1210 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211
23596
9fa72351c18f patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
1212 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
1213 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
1214 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
1215 enddef
9fa72351c18f patch 8.2.2340: win_execute() unexpectedly returns number zero when failing
Bram Moolenaar <Bram@vim.org>
parents: 23594
diff changeset
1216
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 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
1218 split
23072
4b398a229b0b patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents: 22936
diff changeset
1219 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
1220 close
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 enddef
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222
23404
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1223 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
1224 split
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1225 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
1226 wincmd _
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1227 exe cmd
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1228 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
1229 close
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1230 enddef
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1231
23535
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1232 def Test_winsaveview()
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1233 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
1234
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1235 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
1236 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
1237 END
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1238 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
1239 enddef
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1240
98185d3dd369 patch 8.2.2310: Vim9: winsaveview() return type is too generic
Bram Moolenaar <Bram@vim.org>
parents: 23485
diff changeset
1241
23404
a6b6bcc004f2 patch 8.2.2245: Vim9: return value of winrestcmd() cannot be executed
Bram Moolenaar <Bram@vim.org>
parents: 23350
diff changeset
1242
22655
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243
eabe2c1444ea patch 8.2.1876: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker