Mercurial > vim
annotate src/testdir/test_vim9_func.vim @ 28533:b2f93ab72fdc
Added tag v8.2.4790 for changeset 11387538e7c481cb723d74feb6898dcb48bed0d0
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 19 Apr 2022 16:45:03 +0200 |
parents | f24d4826e6bf |
children | c428a4e53b9c |
rev | line source |
---|---|
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test various aspects of the Vim9 script language. |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 source check.vim |
22155
de47cb7b41e6
patch 8.2.1627: Vim9: cannot pass "true" to submatch/term_gettty/term_start
Bram Moolenaar <Bram@vim.org>
parents:
22149
diff
changeset
|
4 source term_util.vim |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 source view_util.vim |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
6 import './vim9.vim' as v9 |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
7 source screendump.vim |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 func Test_def_basic() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 def SomeFunc(): string |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 return 'yes' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 enddef |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
13 call SomeFunc()->assert_equal('yes') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 endfunc |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
22586
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
16 func Test_compiling_error() |
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
17 " use a terminal to see the whole error message |
22584
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
18 CheckRunVimInTerminal |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
19 |
22586
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
20 call TestCompilingError() |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
21 call TestCompilingErrorInTry() |
22586
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
22 endfunc |
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
23 |
622294200ccd
patch 8.2.1841: Vim9: test for compilation error fails in normal build
Bram Moolenaar <Bram@vim.org>
parents:
22584
diff
changeset
|
24 def TestCompilingError() |
22584
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
25 var lines =<< trim END |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
26 vim9script |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
27 def Fails() |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
28 echo nothing |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
29 enddef |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
30 defcompile |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
31 END |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
32 writefile(lines, 'XTest_compile_error') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
33 var buf = g:RunVimInTerminal('-S XTest_compile_error', |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
34 {rows: 10, wait_for_ruler: 0}) |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
35 g:WaitForAssert(() => assert_match('Error detected while compiling command line.*Fails.*Variable not found: nothing', |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
36 g:Term_getlines(buf, range(1, 9)))) |
22584
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
37 |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
38 # clean up |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
39 g:StopVimInTerminal(buf) |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
40 delete('XTest_compile_error') |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
41 enddef |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
42 |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
43 def TestCompilingErrorInTry() |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
44 var dir = 'Xdir/autoload' |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
45 mkdir(dir, 'p') |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
46 |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
47 var lines =<< trim END |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
48 vim9script |
27472
55613f0d59bc
patch 8.2.4264: Vim9: can use old style autoload function name
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
49 export def OnlyCompiled() |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
50 g:runtime = 'yes' |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
51 invalid |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
52 enddef |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
53 END |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
54 writefile(lines, dir .. '/script.vim') |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
55 |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
56 lines =<< trim END |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
57 vim9script |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
58 todo |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
59 try |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
60 script#OnlyCompiled() |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
61 catch /nothing/ |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
62 endtry |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
63 END |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
64 lines[1] = 'set rtp=' .. getcwd() .. '/Xdir' |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
65 writefile(lines, 'XTest_compile_error') |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
66 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
67 var buf = g:RunVimInTerminal('-S XTest_compile_error', {rows: 10, wait_for_ruler: 0}) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
68 g:WaitForAssert(() => assert_match('Error detected while compiling command line.*function script#OnlyCompiled.*Invalid command: invalid', |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
69 g:Term_getlines(buf, range(1, 9)))) |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
70 |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
71 # clean up |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
72 g:StopVimInTerminal(buf) |
24369
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
73 delete('XTest_compile_error') |
a97fb00978f6
patch 8.2.2725: Vim9: message about compiling is wrong when using try/catch
Bram Moolenaar <Bram@vim.org>
parents:
24355
diff
changeset
|
74 delete('Xdir', 'rf') |
22584
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
75 enddef |
c271498e03b2
patch 8.2.1840: Vim9: error message is not clear about compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22541
diff
changeset
|
76 |
24854
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
77 def Test_compile_error_in_called_function() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
78 var lines =<< trim END |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
79 vim9script |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
80 var n: number |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
81 def Foo() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
82 &hls = n |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
83 enddef |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
84 def Bar() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
85 Foo() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
86 enddef |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
87 silent! Foo() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
88 Bar() |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
89 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
90 v9.CheckScriptFailureList(lines, ['E1012:', 'E1191:']) |
24854
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
91 enddef |
c9ccb1976049
patch 8.2.2965: Vim9: crash when calling function that failed to compile
Bram Moolenaar <Bram@vim.org>
parents:
24826
diff
changeset
|
92 |
24988
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
93 def Test_wrong_function_name() |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
94 var lines =<< trim END |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
95 vim9script |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
96 func _Foo() |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
97 echo 'foo' |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
98 endfunc |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
99 END |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
100 v9.CheckScriptFailure(lines, 'E1267:') |
24988
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
101 |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
102 lines =<< trim END |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
103 vim9script |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
104 def _Foo() |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
105 echo 'foo' |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
106 enddef |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
107 END |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
108 v9.CheckScriptFailure(lines, 'E1267:') |
27869
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
109 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
110 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
111 vim9script |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
112 var Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
113 function Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
114 endfunction |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
115 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
116 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
117 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
118 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
119 vim9script |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
120 var Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
121 def Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
122 enddef |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
123 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
124 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
125 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
126 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
127 vim9script |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
128 g:Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
129 function g:Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
130 endfunction |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
131 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
132 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
133 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
134 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
135 let s:Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
136 def Define() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
137 function s:Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
138 endfunction |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
139 enddef |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
140 defcompile |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
141 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
142 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
143 delfunc g:Define |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
144 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
145 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
146 let s:Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
147 def Define() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
148 def Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
149 enddef |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
150 enddef |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
151 defcompile |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
152 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
153 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
154 delfunc g:Define |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
155 |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
156 lines =<< trim END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
157 let g:Object = {} |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
158 def Define() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
159 function g:Object.Method() |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
160 endfunction |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
161 enddef |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
162 defcompile |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
163 END |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
164 v9.CheckScriptFailure(lines, 'E1182:') |
6a0ecde89d35
patch 8.2.4460: Vim9: wrong error for defining dict function
Bram Moolenaar <Bram@vim.org>
parents:
27798
diff
changeset
|
165 delfunc g:Define |
24988
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
166 enddef |
494112d2aa93
patch 8.2.3031: no error if a function name starts with an underscore
Bram Moolenaar <Bram@vim.org>
parents:
24890
diff
changeset
|
167 |
24436
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
168 def Test_autoload_name_mismatch() |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
169 var dir = 'Xdir/autoload' |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
170 mkdir(dir, 'p') |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
171 |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
172 var lines =<< trim END |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
173 vim9script |
27472
55613f0d59bc
patch 8.2.4264: Vim9: can use old style autoload function name
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
174 export def NoFunction() |
24436
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
175 # comment |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
176 g:runtime = 'yes' |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
177 enddef |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
178 END |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
179 writefile(lines, dir .. '/script.vim') |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
180 |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
181 var save_rtp = &rtp |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
182 exe 'set rtp=' .. getcwd() .. '/Xdir' |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
183 lines =<< trim END |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
184 call script#Function() |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
185 END |
27472
55613f0d59bc
patch 8.2.4264: Vim9: can use old style autoload function name
Bram Moolenaar <Bram@vim.org>
parents:
27464
diff
changeset
|
186 v9.CheckScriptFailure(lines, 'E117:', 1) |
24436
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
187 |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
188 &rtp = save_rtp |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
189 delete(dir, 'rf') |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
190 enddef |
ccdd5e9a3763
patch 8.2.2758: Vim9: wrong line number for autoload function with wrong name
Bram Moolenaar <Bram@vim.org>
parents:
24420
diff
changeset
|
191 |
24874
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
192 def Test_autoload_names() |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
193 var dir = 'Xdir/autoload' |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
194 mkdir(dir, 'p') |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
195 |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
196 var lines =<< trim END |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
197 func foobar#function() |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
198 return 'yes' |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
199 endfunc |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
200 let foobar#var = 'no' |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
201 END |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
202 writefile(lines, dir .. '/foobar.vim') |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
203 |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
204 var save_rtp = &rtp |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
205 exe 'set rtp=' .. getcwd() .. '/Xdir' |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
206 |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
207 lines =<< trim END |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
208 assert_equal('yes', foobar#function()) |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
209 var Function = foobar#function |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
210 assert_equal('yes', Function()) |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
211 |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
212 assert_equal('no', foobar#var) |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
213 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
214 v9.CheckDefAndScriptSuccess(lines) |
24874
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
215 |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
216 &rtp = save_rtp |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
217 delete(dir, 'rf') |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
218 enddef |
14b0b35d8488
patch 8.2.2975: Vim9: can only use an autoload function name as a string
Bram Moolenaar <Bram@vim.org>
parents:
24858
diff
changeset
|
219 |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
220 def Test_autoload_error_in_script() |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
221 var dir = 'Xdir/autoload' |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
222 mkdir(dir, 'p') |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
223 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
224 var lines =<< trim END |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
225 func scripterror#function() |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
226 let g:called_function = 'yes' |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
227 endfunc |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
228 let 0 = 1 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
229 END |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
230 writefile(lines, dir .. '/scripterror.vim') |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
231 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
232 var save_rtp = &rtp |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
233 exe 'set rtp=' .. getcwd() .. '/Xdir' |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
234 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
235 g:called_function = 'no' |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
236 # The error in the autoload script cannot be checked with assert_fails(), use |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
237 # CheckDefSuccess() instead of CheckDefFailure() |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
238 try |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
239 v9.CheckDefSuccess(['scripterror#function()']) |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
240 catch |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
241 assert_match('E121: Undefined variable: 0', v:exception) |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
242 endtry |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
243 assert_equal('no', g:called_function) |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
244 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
245 lines =<< trim END |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
246 func scriptcaught#function() |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
247 let g:called_function = 'yes' |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
248 endfunc |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
249 try |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
250 let 0 = 1 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
251 catch |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
252 let g:caught = v:exception |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
253 endtry |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
254 END |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
255 writefile(lines, dir .. '/scriptcaught.vim') |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
256 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
257 g:called_function = 'no' |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
258 v9.CheckDefSuccess(['scriptcaught#function()']) |
25609
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
259 assert_match('E121: Undefined variable: 0', g:caught) |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
260 assert_equal('yes', g:called_function) |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
261 |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
262 &rtp = save_rtp |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
263 delete(dir, 'rf') |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
264 enddef |
f8bcd21e6e24
patch 8.2.3341: Vim9: function call aborted despite try/catch
Bram Moolenaar <Bram@vim.org>
parents:
25579
diff
changeset
|
265 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
266 def s:CallRecursive(n: number): number |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
267 return CallRecursive(n + 1) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
268 enddef |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
269 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
270 def s:CallMapRecursive(l: list<number>): number |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
271 return map(l, (_, v) => CallMapRecursive([v]))[0] |
22908
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
272 enddef |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
273 |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
274 def Test_funcdepth_error() |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
275 set maxfuncdepth=10 |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
276 |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
277 var caught = false |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
278 try |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
279 CallRecursive(1) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
280 catch /E132:/ |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
281 caught = true |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
282 endtry |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
283 assert_true(caught) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
284 |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
285 caught = false |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
286 try |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
287 CallMapRecursive([1]) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
288 catch /E132:/ |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
289 caught = true |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
290 endtry |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
291 assert_true(caught) |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
292 |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
293 set maxfuncdepth& |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
294 enddef |
54219df706b5
patch 8.2.2001: Vim9: :def function does not apply 'maxfuncdepth'
Bram Moolenaar <Bram@vim.org>
parents:
22816
diff
changeset
|
295 |
23442
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
296 def Test_endfunc_enddef() |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
297 var lines =<< trim END |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
298 def Test() |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
299 echo 'test' |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
300 endfunc |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
301 enddef |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
302 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
303 v9.CheckScriptFailure(lines, 'E1151:', 3) |
23442
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
304 |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
305 lines =<< trim END |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
306 def Test() |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
307 func Nested() |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
308 echo 'test' |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
309 enddef |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
310 enddef |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
311 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
312 v9.CheckScriptFailure(lines, 'E1152:', 4) |
24208
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
313 |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
314 lines =<< trim END |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
315 def Ok() |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
316 echo 'hello' |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
317 enddef | echo 'there' |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
318 def Bad() |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
319 echo 'hello' |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
320 enddef there |
7a21b2581dce
patch 8.2.2645: using inline function is not properly tested
Bram Moolenaar <Bram@vim.org>
parents:
24156
diff
changeset
|
321 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
322 v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: there', 6) |
23442
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
323 enddef |
f00d6ff51046
patch 8.2.2264: Vim9: no error for mismatched :endfunc or :enddef
Bram Moolenaar <Bram@vim.org>
parents:
23428
diff
changeset
|
324 |
23444
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
325 def Test_missing_endfunc_enddef() |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
326 var lines =<< trim END |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
327 vim9script |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
328 def Test() |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
329 echo 'test' |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
330 endef |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
331 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
332 v9.CheckScriptFailure(lines, 'E1057:', 2) |
23444
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
333 |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
334 lines =<< trim END |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
335 vim9script |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
336 func Some() |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
337 echo 'test' |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
338 enfffunc |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
339 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
340 v9.CheckScriptFailure(lines, 'E126:', 2) |
23444
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
341 enddef |
7278e86c2f70
patch 8.2.2265: error message for missing endfunc/enddef is last line
Bram Moolenaar <Bram@vim.org>
parents:
23442
diff
changeset
|
342 |
23727
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
343 def Test_white_space_before_paren() |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
344 var lines =<< trim END |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
345 vim9script |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
346 def Test () |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
347 echo 'test' |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
348 enddef |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
349 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
350 v9.CheckScriptFailure(lines, 'E1068:', 2) |
23727
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
351 |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
352 lines =<< trim END |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
353 vim9script |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
354 func Test () |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
355 echo 'test' |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
356 endfunc |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
357 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
358 v9.CheckScriptFailure(lines, 'E1068:', 2) |
23727
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
359 |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
360 lines =<< trim END |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
361 def Test () |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
362 echo 'test' |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
363 enddef |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
364 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
365 v9.CheckScriptFailure(lines, 'E1068:', 1) |
23727
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
366 |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
367 lines =<< trim END |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
368 func Test () |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
369 echo 'test' |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
370 endfunc |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
371 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
372 v9.CheckScriptSuccess(lines) |
23727
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
373 enddef |
7d0959080545
patch 8.2.2405: Vim9: no need to allow white space before "(" for :def
Bram Moolenaar <Bram@vim.org>
parents:
23691
diff
changeset
|
374 |
23545
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
375 def Test_enddef_dict_key() |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
376 var d = { |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
377 enddef: 'x', |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
378 endfunc: 'y', |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
379 } |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
380 assert_equal({enddef: 'x', endfunc: 'y'}, d) |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
381 enddef |
987fb6e8a376
patch 8.2.2315: Vim9: "enddef" as dict key misintepreted as function end
Bram Moolenaar <Bram@vim.org>
parents:
23531
diff
changeset
|
382 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 def ReturnString(): string |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 return 'string' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 def ReturnNumber(): number |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 return 123 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 let g:notNumber = 'string' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 def ReturnGlobal(): number |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 return g:notNumber |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 def Test_return_something() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
398 g:ReturnString()->assert_equal('string') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
399 g:ReturnNumber()->assert_equal(123) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
400 assert_fails('g:ReturnGlobal()', 'E1012: Type mismatch; expected number but got string', '', 1, 'ReturnGlobal') |
27219
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
401 |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
402 var lines =<< trim END |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
403 vim9script |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
404 |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
405 def Msg() |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
406 echomsg 'in Msg()...' |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
407 enddef |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
408 |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
409 def Func() |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
410 return Msg() |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
411 enddef |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
412 defcompile |
47dbeda35910
patch 8.2.4138: Vim9: no error for return with argument when invalid
Bram Moolenaar <Bram@vim.org>
parents:
27022
diff
changeset
|
413 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
414 v9.CheckScriptFailure(lines, 'E1096:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 |
23691
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
417 def Test_check_argument_type() |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
418 var lines =<< trim END |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
419 vim9script |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
420 def Val(a: number, b: number): number |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
421 return 0 |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
422 enddef |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
423 def Func() |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
424 var x: any = true |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
425 Val(0, x) |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
426 enddef |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
427 disass Func |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
428 Func() |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
429 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
430 v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got bool', 2) |
23691
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
431 enddef |
0d56d4f107d8
patch 8.2.2387: runtime type check does not mention argument index
Bram Moolenaar <Bram@vim.org>
parents:
23689
diff
changeset
|
432 |
20909
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
433 def Test_missing_return() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
434 v9.CheckDefFailure(['def Missing(): number', |
20909
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
435 ' if g:cond', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
436 ' echo "no return"', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
437 ' else', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
438 ' return 0', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
439 ' endif' |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
440 'enddef'], 'E1027:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
441 v9.CheckDefFailure(['def Missing(): number', |
20909
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
442 ' if g:cond', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
443 ' return 1', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
444 ' else', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
445 ' echo "no return"', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
446 ' endif' |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
447 'enddef'], 'E1027:') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
448 v9.CheckDefFailure(['def Missing(): number', |
20909
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
449 ' if g:cond', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
450 ' return 1', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
451 ' else', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
452 ' return 2', |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
453 ' endif' |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
454 ' return 3' |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
455 'enddef'], 'E1095:') |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
456 enddef |
0d7465881b06
patch 8.2.1006: Vim9: require unnecessary return statement
Bram Moolenaar <Bram@vim.org>
parents:
20903
diff
changeset
|
457 |
22620
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
458 def Test_return_bool() |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
459 var lines =<< trim END |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
460 vim9script |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
461 def MenuFilter(id: number, key: string): bool |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
462 return popup_filter_menu(id, key) |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
463 enddef |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
464 def YesnoFilter(id: number, key: string): bool |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
465 return popup_filter_yesno(id, key) |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
466 enddef |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
467 defcompile |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
468 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
469 v9.CheckScriptSuccess(lines) |
22620
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
470 enddef |
b5d68d8a5187
patch 8.2.1858: Vim9: filter functions return number instead of bool
Bram Moolenaar <Bram@vim.org>
parents:
22586
diff
changeset
|
471 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 let s:nothing = 0 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 def ReturnNothing() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 s:nothing = 1 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 if true |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 return |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 endif |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 s:nothing = 2 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 def Test_return_nothing() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
482 g:ReturnNothing() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
483 s:nothing->assert_equal(1) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 |
23630
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
486 def Test_return_invalid() |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
487 var lines =<< trim END |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
488 vim9script |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
489 def Func(): invalid |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
490 return xxx |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
491 enddef |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
492 defcompile |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
493 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
494 v9.CheckScriptFailure(lines, 'E1010:', 2) |
23925
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
495 |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
496 lines =<< trim END |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
497 vim9script |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
498 def Test(Fun: func(number): number): list<number> |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
499 return map([1, 2, 3], (_, i) => Fun(i)) |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
500 enddef |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
501 defcompile |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
502 def Inc(nr: number): nr |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
503 return nr + 2 |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
504 enddef |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
505 echo Test(Inc) |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
506 END |
e979bf909fd8
patch 8.2.2505: Vim9: crash after defining function with invalid return type
Bram Moolenaar <Bram@vim.org>
parents:
23923
diff
changeset
|
507 # doing this twice was leaking memory |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
508 v9.CheckScriptFailure(lines, 'E1010:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
509 v9.CheckScriptFailure(lines, 'E1010:') |
23630
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
510 enddef |
ca98d85e92da
patch 8.2.2357: Vim9: crash when parsing function return type fails
Bram Moolenaar <Bram@vim.org>
parents:
23565
diff
changeset
|
511 |
25774
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
512 def Test_return_list_any() |
26925
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
513 # This used to fail but now the actual list type is checked, and since it has |
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
514 # an item of type string it can be used as list<string>. |
25774
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
515 var lines =<< trim END |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
516 vim9script |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
517 def Func(): list<string> |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
518 var l: list<any> |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
519 l->add('string') |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
520 return l |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
521 enddef |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
522 echo Func() |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
523 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
524 v9.CheckScriptSuccess(lines) |
26925
4e77f9961650
patch 8.2.3991: Vim9: error when extending dict<any>
Bram Moolenaar <Bram@vim.org>
parents:
26851
diff
changeset
|
525 |
25774
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
526 lines =<< trim END |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
527 vim9script |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
528 def Func(): list<string> |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
529 var l: list<any> |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
530 l += ['string'] |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
531 return l |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
532 enddef |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
533 echo Func() |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
534 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
535 v9.CheckScriptSuccess(lines) |
25774
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
536 enddef |
9edad9a8cca6
patch 8.2.3422: Vim9: no failure if return type differs from returned var
Bram Moolenaar <Bram@vim.org>
parents:
25737
diff
changeset
|
537 |
28095
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
538 def Test_return_any_two_types() |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
539 var lines =<< trim END |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
540 vim9script |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
541 |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
542 def G(Fn: func(string): any) |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
543 g:result = Fn("hello") |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
544 enddef |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
545 |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
546 def F(a: number, b: string): any |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
547 echo b |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
548 if a > 0 |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
549 return 1 |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
550 else |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
551 return [] |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
552 endif |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
553 enddef |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
554 |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
555 G(function(F, [1])) |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
556 END |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
557 v9.CheckScriptSuccess(lines) |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
558 assert_equal(1, g:result) |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
559 unlet g:result |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
560 enddef |
8a80c48bd103
patch 8.2.4572: Vim9: return type "any" is changed to first returned type
Bram Moolenaar <Bram@vim.org>
parents:
28059
diff
changeset
|
561 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
562 func s:Increment() |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 let g:counter += 1 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 endfunc |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 def Test_call_ufunc_count() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 g:counter = 1 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 Increment() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 Increment() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 Increment() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
571 # works with and without :call |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
572 g:counter->assert_equal(4) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
573 eval g:counter->assert_equal(4) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 unlet g:counter |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 |
27918
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
577 def Test_call_ufunc_failure() |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
578 var lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
579 vim9script |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
580 def Tryit() |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
581 g:Global(1, 2, 3) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
582 enddef |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
583 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
584 func g:Global(a, b, c) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
585 echo a:a a:b a:c |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
586 endfunc |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
587 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
588 defcompile |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
589 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
590 func! g:Global(a, b) |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
591 echo a:a a:b |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
592 endfunc |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
593 Tryit() |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
594 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
595 v9.CheckScriptFailure(lines, 'E118: Too many arguments for function: Global') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
596 delfunc g:Global |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
597 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
598 lines =<< trim END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
599 vim9script |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
600 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
601 g:Ref = function('len') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
602 def Tryit() |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
603 g:Ref('x') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
604 enddef |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
605 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
606 defcompile |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
607 |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
608 g:Ref = function('add') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
609 Tryit() |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
610 END |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
611 v9.CheckScriptFailure(lines, 'E119: Not enough arguments for function: add') |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
612 unlet g:Ref |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
613 enddef |
7d70b420de00
patch 8.2.4484: Vim9: some error messages are not tested
Bram Moolenaar <Bram@vim.org>
parents:
27869
diff
changeset
|
614 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
615 def s:MyVarargs(arg: string, ...rest: list<string>): string |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
616 var res = arg |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 for s in rest |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 res ..= ',' .. s |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 endfor |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 return res |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 def Test_call_varargs() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
624 MyVarargs('one')->assert_equal('one') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
625 MyVarargs('one', 'two')->assert_equal('one,two') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
626 MyVarargs('one', 'two', 'three')->assert_equal('one,two,three') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 |
25737
d923be9d752d
patch 8.2.3404: Vim9: no error for white space before "("
Bram Moolenaar <Bram@vim.org>
parents:
25646
diff
changeset
|
629 def Test_call_white_space() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
630 v9.CheckDefAndScriptFailure(["call Test ('text')"], ['E476:', 'E1068:']) |
25737
d923be9d752d
patch 8.2.3404: Vim9: no error for white space before "("
Bram Moolenaar <Bram@vim.org>
parents:
25646
diff
changeset
|
631 enddef |
d923be9d752d
patch 8.2.3404: Vim9: no error for white space before "("
Bram Moolenaar <Bram@vim.org>
parents:
25646
diff
changeset
|
632 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 def MyDefaultArgs(name = 'string'): string |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 return name |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
637 def s:MyDefaultSecond(name: string, second: bool = true): string |
21345
5dd4cbc1e9e6
patch 8.2.1223: Vim9: invalid type error for function default value
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
638 return second ? name : 'none' |
5dd4cbc1e9e6
patch 8.2.1223: Vim9: invalid type error for function default value
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
639 enddef |
5dd4cbc1e9e6
patch 8.2.1223: Vim9: invalid type error for function default value
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
640 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
641 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 def Test_call_default_args() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
643 g:MyDefaultArgs()->assert_equal('string') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
644 g:MyDefaultArgs(v:none)->assert_equal('string') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
645 g:MyDefaultArgs('one')->assert_equal('one') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
646 assert_fails('g:MyDefaultArgs("one", "two")', 'E118:', '', 4, 'Test_call_default_args') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
648 MyDefaultSecond('test')->assert_equal('test') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
649 MyDefaultSecond('test', true)->assert_equal('test') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
650 MyDefaultSecond('test', false)->assert_equal('none') |
21345
5dd4cbc1e9e6
patch 8.2.1223: Vim9: invalid type error for function default value
Bram Moolenaar <Bram@vim.org>
parents:
21335
diff
changeset
|
651 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
652 var lines =<< trim END |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
653 def MyDefaultThird(name: string, aa = 'aa', bb = 'bb'): string |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
654 return name .. aa .. bb |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
655 enddef |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
656 |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
657 MyDefaultThird('->')->assert_equal('->aabb') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
658 MyDefaultThird('->', v:none)->assert_equal('->aabb') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
659 MyDefaultThird('->', 'xx')->assert_equal('->xxbb') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
660 MyDefaultThird('->', v:none, v:none)->assert_equal('->aabb') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
661 MyDefaultThird('->', 'xx', v:none)->assert_equal('->xxbb') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
662 MyDefaultThird('->', v:none, 'yy')->assert_equal('->aayy') |
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
663 MyDefaultThird('->', 'xx', 'yy')->assert_equal('->xxyy') |
25108
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
664 |
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
665 def DefArg(mandatory: any, optional = mandatory): string |
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
666 return mandatory .. optional |
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
667 enddef |
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
668 DefArg(1234)->assert_equal('12341234') |
de29f9a76233
patch 8.2.3091: Vim9: default argument expr. cannot use previous argument
Bram Moolenaar <Bram@vim.org>
parents:
25046
diff
changeset
|
669 DefArg("ok")->assert_equal('okok') |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
670 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
671 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
672 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
673 v9.CheckScriptFailure(['def Func(arg: number = asdf)', 'enddef', 'defcompile'], 'E1001:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
674 delfunc g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
675 v9.CheckScriptFailure(['def Func(arg: number = "text")', 'enddef', 'defcompile'], 'E1013: Argument 1: type mismatch, expected number but got string') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
676 delfunc g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
677 v9.CheckDefFailure(['def Func(x: number = )', 'enddef'], 'E15:') |
24097
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
678 |
24272
cabed216cc2f
patch 8.2.2677: Vim9: cannot use only some of the default arguments
Bram Moolenaar <Bram@vim.org>
parents:
24218
diff
changeset
|
679 lines =<< trim END |
24097
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
680 vim9script |
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
681 def Func(a = b == 0 ? 1 : 2, b = 0) |
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
682 enddef |
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
683 defcompile |
26d3c1539bcc
patch 8.2.2590: Vim9: default argument value may cause internal error
Bram Moolenaar <Bram@vim.org>
parents:
24069
diff
changeset
|
684 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
685 v9.CheckScriptFailure(lines, 'E1001: Variable not found: b') |
26674
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
686 |
26680
1b288eb2fcdc
patch 8.2.3869: Vim9: type checking for "any" is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26674
diff
changeset
|
687 # using script variable requires matching type or type cast when executed |
26674
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
688 lines =<< trim END |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
689 vim9script |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
690 var a: any |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
691 def Func(arg: string = a) |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
692 echo arg |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
693 enddef |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
694 defcompile |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
695 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
696 v9.CheckScriptSuccess(lines + ['a = "text"', 'Func()']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
697 v9.CheckScriptFailure(lines + ['a = 123', 'Func()'], 'E1013: Argument 1: type mismatch, expected string but got number') |
26674
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
698 |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
699 # using global variable does not require type cast |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
700 lines =<< trim END |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
701 vim9script |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
702 def Func(arg: string = g:str) |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
703 echo arg |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
704 enddef |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
705 g:str = 'works' |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
706 Func() |
38a270fdd3f6
patch 8.2.3866: Vim9: type checking global variables is inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
26650
diff
changeset
|
707 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
708 v9.CheckScriptSuccess(lines) |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
709 enddef |
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
710 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
711 def s:FuncWithComment( # comment |
23511
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
712 a: number, #comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
713 b: bool, # comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
714 c: string) #comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
715 assert_equal(4, a) |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
716 assert_equal(true, b) |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
717 assert_equal('yes', c) |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
718 enddef |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
719 |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
720 def Test_func_with_comments() |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
721 FuncWithComment(4, true, 'yes') |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
722 |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
723 var lines =<< trim END |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
724 def Func(# comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
725 arg: string) |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
726 enddef |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
727 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
728 v9.CheckScriptFailure(lines, 'E125:', 1) |
23511
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
729 |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
730 lines =<< trim END |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
731 def Func( |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
732 arg: string# comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
733 ) |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
734 enddef |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
735 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
736 v9.CheckScriptFailure(lines, 'E475:', 2) |
23511
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
737 |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
738 lines =<< trim END |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
739 def Func( |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
740 arg: string |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
741 )# comment |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
742 enddef |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
743 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
744 v9.CheckScriptFailure(lines, 'E488:', 3) |
23511
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
745 enddef |
7e8703464f01
patch 8.2.2298: Vim9: comment right after "(" of function not recognized
Bram Moolenaar <Bram@vim.org>
parents:
23481
diff
changeset
|
746 |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
747 def Test_nested_function() |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
748 def NestedDef(arg: string): string |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
749 return 'nested ' .. arg |
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
750 enddef |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
751 NestedDef(':def')->assert_equal('nested :def') |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
752 |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
753 func NestedFunc(arg) |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
754 return 'nested ' .. a:arg |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
755 endfunc |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
756 NestedFunc(':func')->assert_equal('nested :func') |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
757 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
758 v9.CheckDefFailure(['def Nested()', 'enddef', 'Nested(66)'], 'E118:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
759 v9.CheckDefFailure(['def Nested(arg: string)', 'enddef', 'Nested()'], 'E119:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
760 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
761 v9.CheckDefFailure(['def s:Nested()', 'enddef'], 'E1075:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
762 v9.CheckDefFailure(['def b:Nested()', 'enddef'], 'E1075:') |
22216
f9b4576a618b
patch 8.2.1657: Vim9: no proper error for nested ":def!"
Bram Moolenaar <Bram@vim.org>
parents:
22214
diff
changeset
|
763 |
23112
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
764 var lines =<< trim END |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
765 def Outer() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
766 def Inner() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
767 # comment |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
768 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
769 def Inner() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
770 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
771 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
772 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
773 v9.CheckDefFailure(lines, 'E1073:') |
23112
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
774 |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
775 lines =<< trim END |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
776 def Outer() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
777 def Inner() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
778 # comment |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
779 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
780 def! Inner() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
781 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
782 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
783 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
784 v9.CheckDefFailure(lines, 'E1117:') |
23112
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
785 |
26735
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
786 lines =<< trim END |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
787 vim9script |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
788 def Outer() |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
789 def Inner() |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
790 g:result = 'ok' |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
791 enddef |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
792 Inner() |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
793 enddef |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
794 Outer() |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
795 Inner() |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
796 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
797 v9.CheckScriptFailure(lines, 'E117: Unknown function: Inner') |
26735
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
798 assert_equal('ok', g:result) |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
799 unlet g:result |
44c7d42dff25
patch 8.2.3896: Vim9: no test for nested function not available later
Bram Moolenaar <Bram@vim.org>
parents:
26680
diff
changeset
|
800 |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
801 lines =<< trim END |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
802 vim9script |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
803 def Outer() |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
804 def _Inner() |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
805 echo 'bad' |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
806 enddef |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
807 _Inner() |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
808 enddef |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
809 defcompile |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
810 END |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
811 v9.CheckScriptFailure(lines, 'E1267:') |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
812 |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
813 lines =<< trim END |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
814 vim9script |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
815 def Outer() |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
816 def g:inner() |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
817 echo 'bad' |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
818 enddef |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
819 g:inner() |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
820 enddef |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
821 defcompile |
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
822 END |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
823 v9.CheckScriptFailure(lines, 'E1267:') |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
824 |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
825 lines =<< trim END |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
826 vim9script |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
827 def g:_Func() |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
828 echo 'bad' |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
829 enddef |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
830 END |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
831 v9.CheckScriptFailure(lines, 'E1267:') |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
832 |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
833 lines =<< trim END |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
834 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
835 def _Func() |
27595
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
836 echo 'bad' |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
837 enddef |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
838 END |
d504745607bc
patch 8.2.4324: Vim9: script-local function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27593
diff
changeset
|
839 v9.CheckScriptFailure(lines, 'E1267:') |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
840 |
23112
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
841 # nested function inside conditional |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
842 lines =<< trim END |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
843 vim9script |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
844 var thecount = 0 |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
845 if true |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
846 def Test(): number |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
847 def TheFunc(): number |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
848 thecount += 1 |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
849 return thecount |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
850 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
851 return TheFunc() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
852 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
853 endif |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
854 defcompile |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
855 assert_equal(1, Test()) |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
856 assert_equal(2, Test()) |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
857 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
858 v9.CheckScriptSuccess(lines) |
24152
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
859 |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
860 # also works when "thecount" is inside the "if" block |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
861 lines =<< trim END |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
862 vim9script |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
863 if true |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
864 var thecount = 0 |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
865 def Test(): number |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
866 def TheFunc(): number |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
867 thecount += 1 |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
868 return thecount |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
869 enddef |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
870 return TheFunc() |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
871 enddef |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
872 endif |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
873 defcompile |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
874 assert_equal(1, Test()) |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
875 assert_equal(2, Test()) |
c308076e225e
patch 8.2.2617: Vim9: script variable in block not found by function
Bram Moolenaar <Bram@vim.org>
parents:
24097
diff
changeset
|
876 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
877 v9.CheckScriptSuccess(lines) |
25632
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
878 |
28173
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
879 # nested function with recursive call |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
880 lines =<< trim END |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
881 vim9script |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
882 |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
883 def MyFunc(): number |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
884 def Fib(n: number): number |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
885 if n < 2 |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
886 return 1 |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
887 endif |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
888 return Fib(n - 2) + Fib(n - 1) |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
889 enddef |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
890 |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
891 return Fib(5) |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
892 enddef |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
893 |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
894 assert_equal(8, MyFunc()) |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
895 END |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
896 v9.CheckScriptSuccess(lines) |
b0c885507de4
patch 8.2.4612: Vim9: cannot use a recursive call in a nested function
Bram Moolenaar <Bram@vim.org>
parents:
28154
diff
changeset
|
897 |
25632
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
898 lines =<< trim END |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
899 vim9script |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
900 def Outer() |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
901 def Inner() |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
902 echo 'hello' |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
903 enddef burp |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
904 enddef |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
905 defcompile |
c204815f3058
patch 8.2.3352: Vim9: error for nested :enddef has wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
25630
diff
changeset
|
906 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
907 v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: burp', 3) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 |
23426
c3c690c8fcbf
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23299
diff
changeset
|
910 def Test_not_nested_function() |
c3c690c8fcbf
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23299
diff
changeset
|
911 echo printf('%d', |
c3c690c8fcbf
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23299
diff
changeset
|
912 function('len')('xxx')) |
c3c690c8fcbf
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23299
diff
changeset
|
913 enddef |
c3c690c8fcbf
patch 8.2.2256: Vim9: cannot use function( after line break in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23299
diff
changeset
|
914 |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
915 func Test_call_default_args_from_func() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
916 call MyDefaultArgs()->assert_equal('string') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
917 call MyDefaultArgs('one')->assert_equal('one') |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
918 call assert_fails('call MyDefaultArgs("one", "two")', 'E118:', '', 3, 'Test_call_default_args_from_func') |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
919 endfunc |
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
920 |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
921 def Test_nested_global_function() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
922 var lines =<< trim END |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
923 vim9script |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
924 def Outer() |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
925 def g:Inner(): string |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
926 return 'inner' |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
927 enddef |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
928 enddef |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
929 defcompile |
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
930 Outer() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
931 g:Inner()->assert_equal('inner') |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
932 delfunc g:Inner |
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
933 Outer() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
934 g:Inner()->assert_equal('inner') |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
935 delfunc g:Inner |
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
936 Outer() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
937 g:Inner()->assert_equal('inner') |
21566
1e3e5058041c
patch 8.2.1333: Vim9: memory leak when using nested global function
Bram Moolenaar <Bram@vim.org>
parents:
21564
diff
changeset
|
938 delfunc g:Inner |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
939 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
940 v9.CheckScriptSuccess(lines) |
21588
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
941 |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
942 lines =<< trim END |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
943 vim9script |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
944 def Outer() |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
945 func g:Inner() |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
946 return 'inner' |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
947 endfunc |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
948 enddef |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
949 defcompile |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
950 Outer() |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
951 g:Inner()->assert_equal('inner') |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
952 delfunc g:Inner |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
953 Outer() |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
954 g:Inner()->assert_equal('inner') |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
955 delfunc g:Inner |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
956 Outer() |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
957 g:Inner()->assert_equal('inner') |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
958 delfunc g:Inner |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
959 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
960 v9.CheckScriptSuccess(lines) |
26323
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
961 |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
962 lines =<< trim END |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
963 vim9script |
3841da4eac23
patch 8.2.3692: Vim9: cannot use :func inside a :def function
Bram Moolenaar <Bram@vim.org>
parents:
26205
diff
changeset
|
964 def Outer() |
21588
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
965 def g:Inner(): string |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
966 return 'inner' |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
967 enddef |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
968 enddef |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
969 defcompile |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
970 Outer() |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
971 Outer() |
9ade1da22402
patch 8.2.1344: Vim9: No test for trying to redefine global function
Bram Moolenaar <Bram@vim.org>
parents:
21586
diff
changeset
|
972 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
973 v9.CheckScriptFailure(lines, "E122:") |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
974 delfunc g:Inner |
21604
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
975 |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
976 lines =<< trim END |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
977 vim9script |
23291
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
978 def Outer() |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
979 def g:Inner() |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
980 echo map([1, 2, 3], (_, v) => v + 1) |
23291
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
981 enddef |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
982 g:Inner() |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
983 enddef |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
984 Outer() |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
985 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
986 v9.CheckScriptSuccess(lines) |
23291
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
987 delfunc g:Inner |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
988 |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
989 lines =<< trim END |
8e1427ac2bce
patch 8.2.2191: Vim9: using wrong name with lambda in nested function
Bram Moolenaar <Bram@vim.org>
parents:
23289
diff
changeset
|
990 vim9script |
21604
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
991 def Func() |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
992 echo 'script' |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
993 enddef |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
994 def Outer() |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
995 def Func() |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
996 echo 'inner' |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
997 enddef |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
998 enddef |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
999 defcompile |
d9c45474cac1
patch 8.2.1352: Vim9: no error for shadowing a script-local function
Bram Moolenaar <Bram@vim.org>
parents:
21602
diff
changeset
|
1000 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1001 v9.CheckScriptFailure(lines, "E1073:", 1) |
26205
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1002 |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1003 lines =<< trim END |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1004 vim9script |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1005 def Func() |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1006 echo 'script' |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1007 enddef |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1008 def Func() |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1009 echo 'script' |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1010 enddef |
9e5e331828da
patch 8.2.3634: error for already defined function uses wrong line number
Bram Moolenaar <Bram@vim.org>
parents:
26203
diff
changeset
|
1011 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1012 v9.CheckScriptFailure(lines, "E1073:", 5) |
21558
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1013 enddef |
1c4d4aa22b37
patch 8.2.1329: Vim9: cannot define global function inside :def function
Bram Moolenaar <Bram@vim.org>
parents:
21544
diff
changeset
|
1014 |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1015 def DefListAll() |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1016 def |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1017 enddef |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1018 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1019 def DefListOne() |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1020 def DefListOne |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1021 enddef |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1022 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1023 def DefListMatches() |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1024 def /DefList |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1025 enddef |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1026 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1027 def Test_nested_def_list() |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1028 var funcs = split(execute('call DefListAll()'), "\n") |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1029 assert_true(len(funcs) > 10) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1030 assert_true(funcs->index('def DefListAll()') >= 0) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1031 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1032 funcs = split(execute('call DefListOne()'), "\n") |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1033 assert_equal([' def DefListOne()', '1 def DefListOne', ' enddef'], funcs) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1034 |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1035 funcs = split(execute('call DefListMatches()'), "\n") |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1036 assert_true(len(funcs) >= 3) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1037 assert_true(funcs->index('def DefListAll()') >= 0) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1038 assert_true(funcs->index('def DefListOne()') >= 0) |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1039 assert_true(funcs->index('def DefListMatches()') >= 0) |
23112
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1040 |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1041 var lines =<< trim END |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1042 vim9script |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1043 def Func() |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1044 def +Func+ |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1045 enddef |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1046 defcompile |
892303d45d2a
patch 8.2.2102: Vim9: not all error messages tested
Bram Moolenaar <Bram@vim.org>
parents:
23102
diff
changeset
|
1047 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1048 v9.CheckScriptFailure(lines, 'E476:', 1) |
22973
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1049 enddef |
4c97c0747017
patch 8.2.2033: Vim9: :def without argument gives compilation error
Bram Moolenaar <Bram@vim.org>
parents:
22969
diff
changeset
|
1050 |
27762
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1051 def Test_global_function_not_found() |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1052 var lines =<< trim END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1053 g:Ref = 123 |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1054 call g:Ref() |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1055 END |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1056 v9.CheckDefExecAndScriptFailure(lines, ['E117:', 'E1085:'], 2) |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1057 enddef |
3196066c5795
patch 8.2.4407: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27756
diff
changeset
|
1058 |
21586
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1059 def Test_global_local_function() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1060 var lines =<< trim END |
21586
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1061 vim9script |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1062 def g:Func(): string |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1063 return 'global' |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1064 enddef |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1065 def Func(): string |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1066 return 'local' |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1067 enddef |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1068 g:Func()->assert_equal('global') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1069 Func()->assert_equal('local') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
1070 delfunc g:Func |
21586
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1071 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1072 v9.CheckScriptSuccess(lines) |
21747
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1073 |
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1074 lines =<< trim END |
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1075 vim9script |
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1076 def g:Funcy() |
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1077 echo 'funcy' |
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1078 enddef |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
1079 Funcy() |
21747
7e1316c6d0eb
patch 8.2.1423: Vim9: find global function when looking for script-local
Bram Moolenaar <Bram@vim.org>
parents:
21693
diff
changeset
|
1080 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1081 v9.CheckScriptFailure(lines, 'E117:') |
21586
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1082 enddef |
5470c36ed7e6
patch 8.2.1343: Vim9: cannot find global function when using g:
Bram Moolenaar <Bram@vim.org>
parents:
21566
diff
changeset
|
1083 |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1084 def Test_local_function_shadows_global() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1085 var lines =<< trim END |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1086 vim9script |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1087 def g:Gfunc(): string |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1088 return 'global' |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1089 enddef |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1090 def AnotherFunc(): number |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1091 var Gfunc = function('len') |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1092 return Gfunc('testing') |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1093 enddef |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1094 g:Gfunc()->assert_equal('global') |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1095 AnotherFunc()->assert_equal(7) |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1096 delfunc g:Gfunc |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1097 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1098 v9.CheckScriptSuccess(lines) |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1099 |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1100 lines =<< trim END |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1101 vim9script |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1102 def g:Func(): string |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1103 return 'global' |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1104 enddef |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1105 def AnotherFunc() |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1106 g:Func = function('len') |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1107 enddef |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1108 AnotherFunc() |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1109 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1110 v9.CheckScriptFailure(lines, 'E705:') |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1111 delfunc g:Func |
24355
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1112 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1113 # global function is not found with g: prefix |
24355
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1114 lines =<< trim END |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1115 vim9script |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1116 def g:Func(): string |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1117 return 'global' |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1118 enddef |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1119 def AnotherFunc(): string |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1120 return Func() |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1121 enddef |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1122 assert_equal('global', AnotherFunc()) |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1123 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1124 v9.CheckScriptFailure(lines, 'E117:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1125 delfunc g:Func |
24355
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1126 |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1127 lines =<< trim END |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1128 vim9script |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1129 def g:Func(): string |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1130 return 'global' |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1131 enddef |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1132 assert_equal('global', g:Func()) |
24355
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1133 delfunc g:Func |
beb395ca3e2f
patch 8.2.2718: Vim9: no explicit test for using a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
24272
diff
changeset
|
1134 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1135 v9.CheckScriptSuccess(lines) |
26974
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1136 |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1137 # This does not shadow "i" which is visible only inside the for loop |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1138 lines =<< trim END |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1139 vim9script |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1140 |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1141 def Foo(i: number) |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1142 echo i |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1143 enddef |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1144 |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1145 for i in range(3) |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1146 # Foo() is compiled here |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1147 Foo(i) |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1148 endfor |
fceb494e22de
patch 8.2.4016: Vim9: incorrect error for argument that is shadowing var
Bram Moolenaar <Bram@vim.org>
parents:
26960
diff
changeset
|
1149 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1150 v9.CheckScriptSuccess(lines) |
22236
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1151 enddef |
3d0632b260fd
patch 8.2.1667: local function name cannot shadow a global function name
Bram Moolenaar <Bram@vim.org>
parents:
22222
diff
changeset
|
1152 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 func TakesOneArg(arg) |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 echo a:arg |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 endfunc |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 def Test_call_wrong_args() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1158 v9.CheckDefFailure(['g:TakesOneArg()'], 'E119:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1159 v9.CheckDefFailure(['g:TakesOneArg(11, 22)'], 'E118:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1160 v9.CheckDefFailure(['bufnr(xxx)'], 'E1001:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1161 v9.CheckScriptFailure(['def Func(Ref: func(s: string))'], 'E475:') |
21969
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1162 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1163 var lines =<< trim END |
21969
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1164 vim9script |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1165 def Func(s: string) |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1166 echo s |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1167 enddef |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1168 Func([]) |
ba2415df82d7
patch 8.2.1534: Vim9: type error for argument type is not at call position
Bram Moolenaar <Bram@vim.org>
parents:
21967
diff
changeset
|
1169 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1170 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got list<unknown>', 5) |
22318
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1171 |
26851
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1172 # argument name declared earlier is found when declaring a function |
22318
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1173 lines =<< trim END |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1174 vim9script |
23996
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1175 var name = 'piet' |
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1176 def FuncOne(name: string) |
27609
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1177 echo name |
23996
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1178 enddef |
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1179 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1180 v9.CheckScriptFailure(lines, 'E1168:') |
23996
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1181 |
27609
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1182 # same, inside the same block |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1183 lines =<< trim END |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1184 vim9script |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1185 if true |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1186 var name = 'piet' |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1187 def FuncOne(name: string) |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1188 echo name |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1189 enddef |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1190 endif |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1191 END |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1192 v9.CheckScriptFailure(lines, 'E1168:') |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1193 |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1194 # variable in other block is OK |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1195 lines =<< trim END |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1196 vim9script |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1197 if true |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1198 var name = 'piet' |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1199 endif |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1200 def FuncOne(name: string) |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1201 echo name |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1202 enddef |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1203 END |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1204 v9.CheckScriptSuccess(lines) |
766a329fe5bb
patch 8.2.4331: Vim9: no test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27595
diff
changeset
|
1205 |
27611
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1206 # with another variable in another block |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1207 lines =<< trim END |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1208 vim9script |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1209 if true |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1210 var name = 'piet' |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1211 # define a function so that the variable isn't cleared |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1212 def GetItem(): string |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1213 return item |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1214 enddef |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1215 endif |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1216 if true |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1217 var name = 'peter' |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1218 def FuncOne(name: string) |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1219 echo name |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1220 enddef |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1221 endif |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1222 END |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1223 v9.CheckScriptFailure(lines, 'E1168:') |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1224 |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1225 # only variable in another block is OK |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1226 lines =<< trim END |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1227 vim9script |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1228 if true |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1229 var name = 'piet' |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1230 # define a function so that the variable isn't cleared |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1231 def GetItem(): string |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1232 return item |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1233 enddef |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1234 endif |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1235 if true |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1236 def FuncOne(name: string) |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1237 echo name |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1238 enddef |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1239 endif |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1240 END |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1241 v9.CheckScriptSuccess(lines) |
e311a80f8cbe
patch 8.2.4332: Vim9: incomplete test for existing script variable in block
Bram Moolenaar <Bram@vim.org>
parents:
27609
diff
changeset
|
1242 |
26851
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1243 # argument name declared later is only found when compiling |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1244 lines =<< trim END |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1245 vim9script |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1246 def FuncOne(name: string) |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1247 echo nr |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1248 enddef |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1249 var name = 'piet' |
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1250 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1251 v9.CheckScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1252 v9.CheckScriptFailure(lines + ['defcompile'], 'E1168:') |
26851
15913ba6363e
patch 8.2.3954: Vim9: no error for shadowing if script var is declared later
Bram Moolenaar <Bram@vim.org>
parents:
26845
diff
changeset
|
1253 |
23996
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1254 lines =<< trim END |
c192411b27e8
patch 8.2.2540: Vim9: no error for using script var name for argument
Bram Moolenaar <Bram@vim.org>
parents:
23940
diff
changeset
|
1255 vim9script |
22318
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1256 def FuncOne(nr: number) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1257 echo nr |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1258 enddef |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1259 def FuncTwo() |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1260 FuncOne() |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1261 enddef |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1262 defcompile |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1263 END |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1264 writefile(lines, 'Xscript') |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1265 var didCatch = false |
22318
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1266 try |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1267 source Xscript |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1268 catch |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1269 assert_match('E119: Not enough arguments for function: <SNR>\d\+_FuncOne', v:exception) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1270 assert_match('Xscript\[8\]..function <SNR>\d\+_FuncTwo, line 1', v:throwpoint) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1271 didCatch = true |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1272 endtry |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1273 assert_true(didCatch) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1274 |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1275 lines =<< trim END |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1276 vim9script |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1277 def FuncOne(nr: number) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1278 echo nr |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1279 enddef |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1280 def FuncTwo() |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1281 FuncOne(1, 2) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1282 enddef |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1283 defcompile |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1284 END |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1285 writefile(lines, 'Xscript') |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1286 didCatch = false |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1287 try |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1288 source Xscript |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1289 catch |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1290 assert_match('E118: Too many arguments for function: <SNR>\d\+_FuncOne', v:exception) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1291 assert_match('Xscript\[8\]..function <SNR>\d\+_FuncTwo, line 1', v:throwpoint) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1292 didCatch = true |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1293 endtry |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1294 assert_true(didCatch) |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1295 |
3f5f96a8dd83
patch 8.2.1708: Vim9: error message for function has unpritable characters
Bram Moolenaar <Bram@vim.org>
parents:
22314
diff
changeset
|
1296 delete('Xscript') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1299 def Test_call_funcref_wrong_args() |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1300 var head =<< trim END |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1301 vim9script |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1302 def Func3(a1: string, a2: number, a3: list<number>) |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1303 echo a1 .. a2 .. a3[0] |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1304 enddef |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1305 def Testme() |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1306 var funcMap: dict<func> = {func: Func3} |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1307 END |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1308 var tail =<< trim END |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1309 enddef |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1310 Testme() |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1311 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1312 v9.CheckScriptSuccess(head + ["funcMap['func']('str', 123, [1, 2, 3])"] + tail) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1313 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1314 v9.CheckScriptFailure(head + ["funcMap['func']('str', 123)"] + tail, 'E119:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1315 v9.CheckScriptFailure(head + ["funcMap['func']('str', 123, [1], 4)"] + tail, 'E118:') |
23527
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1316 |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1317 var lines =<< trim END |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1318 vim9script |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1319 var Ref: func(number): any |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1320 Ref = (j) => !j |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1321 echo Ref(false) |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1322 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1323 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) |
23527
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1324 |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1325 lines =<< trim END |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1326 vim9script |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1327 var Ref: func(number): any |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1328 Ref = (j) => !j |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1329 call Ref(false) |
27ca5534a408
patch 8.2.2306: Vim9: when using function reference type is not checked
Bram Moolenaar <Bram@vim.org>
parents:
23511
diff
changeset
|
1330 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1331 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got bool', 4) |
23252
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1332 enddef |
35583da6397e
patch 8.2.2172: Vim9: number of arguments is not always checked
Bram Moolenaar <Bram@vim.org>
parents:
23249
diff
changeset
|
1333 |
22816
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1334 def Test_call_lambda_args() |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1335 var lines =<< trim END |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1336 var Callback = (..._) => 'anything' |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1337 assert_equal('anything', Callback()) |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1338 assert_equal('anything', Callback(1)) |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1339 assert_equal('anything', Callback('a', 2)) |
24402
009a540f16a6
patch 8.2.2741: Vim9: Partial call does not check right arguments
Bram Moolenaar <Bram@vim.org>
parents:
24400
diff
changeset
|
1340 |
009a540f16a6
patch 8.2.2741: Vim9: Partial call does not check right arguments
Bram Moolenaar <Bram@vim.org>
parents:
24400
diff
changeset
|
1341 assert_equal('xyz', ((a: string): string => a)('xyz')) |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1342 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1343 v9.CheckDefAndScriptSuccess(lines) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1344 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1345 v9.CheckDefFailure(['echo ((i) => 0)()'], |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
1346 'E119: Not enough arguments for function: ((i) => 0)()') |
22816
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1347 |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1348 lines =<< trim END |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
1349 var Ref = (x: number, y: number) => x + y |
22816
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1350 echo Ref(1, 'x') |
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1351 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1352 v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected number but got string') |
23481
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1353 |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1354 lines =<< trim END |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1355 var Ref: func(job, string, number) |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1356 Ref = (x, y) => 0 |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1357 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1358 v9.CheckDefAndScriptFailure(lines, 'E1012:') |
23481
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1359 |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1360 lines =<< trim END |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1361 var Ref: func(job, string) |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1362 Ref = (x, y, z) => 0 |
62fe9a7fd582
patch 8.2.2283: Vim9: crash when lambda has fewer arguments than expected
Bram Moolenaar <Bram@vim.org>
parents:
23444
diff
changeset
|
1363 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1364 v9.CheckDefAndScriptFailure(lines, 'E1012:') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1365 |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1366 lines =<< trim END |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1367 var one = 1 |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1368 var l = [1, 2, 3] |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1369 echo map(l, (one) => one) |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1370 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1371 v9.CheckDefFailure(lines, 'E1167:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1372 v9.CheckScriptFailure(['vim9script'] + lines, 'E1168:') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1373 |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1374 lines =<< trim END |
25038
efdb9608cc11
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
25030
diff
changeset
|
1375 var Ref: func(any, ?any): bool |
efdb9608cc11
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
25030
diff
changeset
|
1376 Ref = (_, y = 1) => false |
efdb9608cc11
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
25030
diff
changeset
|
1377 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1378 v9.CheckDefAndScriptFailure(lines, 'E1172:') |
25038
efdb9608cc11
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
25030
diff
changeset
|
1379 |
efdb9608cc11
patch 8.2.3056: Vim9: using default value in lambda gives confusing error
Bram Moolenaar <Bram@vim.org>
parents:
25030
diff
changeset
|
1380 lines =<< trim END |
25042
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1381 var a = 0 |
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1382 var b = (a == 0 ? 1 : 2) |
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1383 assert_equal(1, b) |
25046
2f702d19013a
patch 8.2.3060: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25042
diff
changeset
|
1384 var txt = 'a' |
2f702d19013a
patch 8.2.3060: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25042
diff
changeset
|
1385 b = (txt =~ 'x' ? 1 : 2) |
2f702d19013a
patch 8.2.3060: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25042
diff
changeset
|
1386 assert_equal(2, b) |
25042
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1387 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1388 v9.CheckDefAndScriptSuccess(lines) |
25042
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1389 |
3f39b6b73019
patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis
Bram Moolenaar <Bram@vim.org>
parents:
25038
diff
changeset
|
1390 lines =<< trim END |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1391 def ShadowLocal() |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1392 var one = 1 |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1393 var l = [1, 2, 3] |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1394 echo map(l, (one) => one) |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1395 enddef |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1396 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1397 v9.CheckDefFailure(lines, 'E1167:') |
24033
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1398 |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1399 lines =<< trim END |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1400 def Shadowarg(one: number) |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1401 var l = [1, 2, 3] |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1402 echo map(l, (one) => one) |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1403 enddef |
308d29307910
patch 8.2.2558: no error if a lambda argument shadows a variable
Bram Moolenaar <Bram@vim.org>
parents:
23996
diff
changeset
|
1404 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1405 v9.CheckDefFailure(lines, 'E1167:') |
24398
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
1406 |
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
1407 lines =<< trim END |
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
1408 echo ((a) => a)('aa', 'bb') |
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
1409 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1410 v9.CheckDefAndScriptFailure(lines, 'E118:', 1) |
25316
0716cc2e4a8b
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda
Bram Moolenaar <Bram@vim.org>
parents:
25276
diff
changeset
|
1411 |
0716cc2e4a8b
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda
Bram Moolenaar <Bram@vim.org>
parents:
25276
diff
changeset
|
1412 lines =<< trim END |
0716cc2e4a8b
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda
Bram Moolenaar <Bram@vim.org>
parents:
25276
diff
changeset
|
1413 echo 'aa'->((a) => a)('bb') |
0716cc2e4a8b
patch 8.2.3195: Vim9: unclear error when passing too many arguments to lambda
Bram Moolenaar <Bram@vim.org>
parents:
25276
diff
changeset
|
1414 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1415 v9.CheckDefFailure(lines, 'E118: Too many arguments for function: ->((a) => a)(''bb'')', 1) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1416 v9.CheckScriptFailure(['vim9script'] + lines, 'E118: Too many arguments for function: <lambda>', 2) |
22816
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1417 enddef |
8a5369f5f2b4
patch 8.2.1956: Vim9: cannot specify argument types for lambda
Bram Moolenaar <Bram@vim.org>
parents:
22760
diff
changeset
|
1418 |
26203
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1419 def Test_lambda_line_nr() |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1420 var lines =<< trim END |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1421 vim9script |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1422 # comment |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1423 # comment |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1424 var id = timer_start(1'000, (_) => 0) |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1425 var out = execute('verbose ' .. timer_info(id)[0].callback |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1426 ->string() |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1427 ->substitute("('\\|')", ' ', 'g')) |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1428 assert_match('Last set from .* line 4', out) |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1429 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1430 v9.CheckScriptSuccess(lines) |
26203
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1431 enddef |
a968027f8a2c
patch 8.2.3633: Vim9: line number of lambda is off by one
Bram Moolenaar <Bram@vim.org>
parents:
26053
diff
changeset
|
1432 |
24156
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1433 def FilterWithCond(x: string, Cond: func(string): bool): bool |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1434 return Cond(x) |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1435 enddef |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1436 |
23808
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1437 def Test_lambda_return_type() |
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1438 var lines =<< trim END |
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1439 var Ref = (): => 123 |
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1440 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1441 v9.CheckDefAndScriptFailure(lines, 'E1157:', 1) |
24156
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1442 |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
1443 # no space before the return type |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
1444 lines =<< trim END |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
1445 var Ref = (x):number => x + 1 |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
1446 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1447 v9.CheckDefAndScriptFailure(lines, 'E1069:', 1) |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
1448 |
24156
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1449 # this works |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1450 for x in ['foo', 'boo'] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1451 echo g:FilterWithCond(x, (v) => v =~ '^b') |
24156
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1452 endfor |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1453 |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1454 # this fails |
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1455 lines =<< trim END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1456 echo g:FilterWithCond('foo', (v) => v .. '^b') |
24156
a358fa462560
patch 8.2.2619: Vim9: no test for return type of lambda
Bram Moolenaar <Bram@vim.org>
parents:
24152
diff
changeset
|
1457 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1458 v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected func(string): bool but got func(any): string', 1) |
24890
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1459 |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1460 lines =<< trim END |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1461 var Lambda1 = (x) => { |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1462 return x |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1463 } |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1464 assert_equal('asdf', Lambda1('asdf')) |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1465 var Lambda2 = (x): string => { |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1466 return x |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1467 } |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1468 assert_equal('foo', Lambda2('foo')) |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1469 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1470 v9.CheckDefAndScriptSuccess(lines) |
24890
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1471 |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1472 lines =<< trim END |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1473 var Lambda = (x): string => { |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1474 return x |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1475 } |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1476 echo Lambda(['foo']) |
0cba2be8cbd7
patch 8.2.2983: Vim9: an inline function requires specifying the return type
Bram Moolenaar <Bram@vim.org>
parents:
24874
diff
changeset
|
1477 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1478 v9.CheckDefExecAndScriptFailure(lines, 'E1012:') |
23808
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1479 enddef |
baf9069f64ca
patch 8.2.2445: Vim9: no proper error for lambda missing return type
Bram Moolenaar <Bram@vim.org>
parents:
23727
diff
changeset
|
1480 |
23171
bb7531f77529
patch 8.2.2131: Vim9: crash when lambda uses same var as assignment
Bram Moolenaar <Bram@vim.org>
parents:
23112
diff
changeset
|
1481 def Test_lambda_uses_assigned_var() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1482 v9.CheckDefSuccess([ |
23171
bb7531f77529
patch 8.2.2131: Vim9: crash when lambda uses same var as assignment
Bram Moolenaar <Bram@vim.org>
parents:
23112
diff
changeset
|
1483 'var x: any = "aaa"' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
1484 'x = filter(["bbb"], (_, v) => v =~ x)']) |
23171
bb7531f77529
patch 8.2.2131: Vim9: crash when lambda uses same var as assignment
Bram Moolenaar <Bram@vim.org>
parents:
23112
diff
changeset
|
1485 enddef |
bb7531f77529
patch 8.2.2131: Vim9: crash when lambda uses same var as assignment
Bram Moolenaar <Bram@vim.org>
parents:
23112
diff
changeset
|
1486 |
24061
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1487 def Test_pass_legacy_lambda_to_def_func() |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1488 var lines =<< trim END |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1489 vim9script |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1490 func Foo() |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1491 eval s:Bar({x -> 0}) |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1492 endfunc |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1493 def Bar(y: any) |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1494 enddef |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1495 Foo() |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1496 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1497 v9.CheckScriptSuccess(lines) |
24996
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1498 |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1499 lines =<< trim END |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1500 vim9script |
28123
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
1501 def g:TestFunc(F: func) |
24996
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1502 enddef |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1503 legacy call g:TestFunc({-> 0}) |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1504 delfunc g:TestFunc |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1505 |
28123
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
1506 def g:TestFunc(F: func(number)) |
24996
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1507 enddef |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1508 legacy call g:TestFunc({nr -> 0}) |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1509 delfunc g:TestFunc |
0136c6ee1961
patch 8.2.3035: Vim9: crash when calling :def function with partial
Bram Moolenaar <Bram@vim.org>
parents:
24988
diff
changeset
|
1510 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1511 v9.CheckScriptSuccess(lines) |
24061
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1512 enddef |
d6489b4eb14e
patch 8.2.2572: Vim9: crash when getting the types for a legacy function
Bram Moolenaar <Bram@vim.org>
parents:
24033
diff
changeset
|
1513 |
26053
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1514 def Test_lambda_in_reduce_line_break() |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1515 # this was using freed memory |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1516 var lines =<< trim END |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1517 vim9script |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1518 const result: dict<number> = |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1519 ['Bob', 'Sam', 'Cat', 'Bob', 'Cat', 'Cat'] |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1520 ->reduce((acc, val) => { |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1521 if has_key(acc, val) |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1522 acc[val] += 1 |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1523 return acc |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1524 else |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1525 acc[val] = 1 |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1526 return acc |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1527 endif |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1528 }, {}) |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1529 assert_equal({Bob: 2, Sam: 1, Cat: 3}, result) |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1530 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1531 v9.CheckScriptSuccess(lines) |
26053
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1532 enddef |
e861c5aaedd8
patch 8.2.3560: using freed memory with lambda
Bram Moolenaar <Bram@vim.org>
parents:
25800
diff
changeset
|
1533 |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1534 def Test_set_opfunc_to_lambda() |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1535 var lines =<< trim END |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1536 vim9script |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1537 nnoremap <expr> <F4> <SID>CountSpaces() .. '_' |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1538 def CountSpaces(type = ''): string |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1539 if type == '' |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1540 &operatorfunc = (t) => CountSpaces(t) |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1541 return 'g@' |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1542 endif |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1543 normal! '[V']y |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1544 g:result = getreg('"')->count(' ') |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1545 return '' |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1546 enddef |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1547 new |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1548 'a b c d e'->setline(1) |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1549 feedkeys("\<F4>", 'x') |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1550 assert_equal(4, g:result) |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1551 bwipe! |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1552 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1553 v9.CheckScriptSuccess(lines) |
26470
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1554 enddef |
ff0310e6f889
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Bram Moolenaar <Bram@vim.org>
parents:
26378
diff
changeset
|
1555 |
26528
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1556 def Test_set_opfunc_to_global_function() |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1557 var lines =<< trim END |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1558 vim9script |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1559 def g:CountSpaces(type = ''): string |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1560 normal! '[V']y |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1561 g:result = getreg('"')->count(' ') |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1562 return '' |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1563 enddef |
26594
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1564 # global function works at script level |
26528
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1565 &operatorfunc = g:CountSpaces |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1566 new |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1567 'a b c d e'->setline(1) |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1568 feedkeys("g@_", 'x') |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1569 assert_equal(4, g:result) |
26594
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1570 |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1571 &operatorfunc = '' |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1572 g:result = 0 |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1573 # global function works in :def function |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1574 def Func() |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1575 &operatorfunc = g:CountSpaces |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1576 enddef |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1577 Func() |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1578 feedkeys("g@_", 'x') |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1579 assert_equal(4, g:result) |
b12d8a5af20e
patch 8.2.3826: Vim9: using "g:Func" as funcref doesn't work in :def function
Bram Moolenaar <Bram@vim.org>
parents:
26564
diff
changeset
|
1580 |
26528
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1581 bwipe! |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1582 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1583 v9.CheckScriptSuccess(lines) |
26528
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1584 &operatorfunc = '' |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1585 enddef |
4d8226001391
patch 8.2.3793: using "g:Func" as a funcref does not work in script context
Bram Moolenaar <Bram@vim.org>
parents:
26506
diff
changeset
|
1586 |
26530
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1587 def Test_use_script_func_name_with_prefix() |
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1588 var lines =<< trim END |
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1589 vim9script |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
1590 func g:Getit() |
26530
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1591 return 'it' |
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1592 endfunc |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
1593 var Fn = g:Getit |
26530
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1594 assert_equal('it', Fn()) |
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1595 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1596 v9.CheckScriptSuccess(lines) |
26530
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1597 enddef |
2fbd05a873e3
patch 8.2.3794: Vim9: cannot find script-local func using "s:"
Bram Moolenaar <Bram@vim.org>
parents:
26528
diff
changeset
|
1598 |
26482
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1599 def Test_lambda_type_allocated() |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1600 # Check that unreferencing a partial using a lambda can use the variable type |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1601 # after the lambda has been freed and does not leak memory. |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1602 var lines =<< trim END |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1603 vim9script |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1604 |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1605 func MyomniFunc1(val, findstart, base) |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1606 return a:findstart ? 0 : [] |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1607 endfunc |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1608 |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1609 var Lambda = (a, b) => MyomniFunc1(19, a, b) |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1610 &omnifunc = Lambda |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1611 Lambda = (a, b) => MyomniFunc1(20, a, b) |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1612 &omnifunc = string(Lambda) |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1613 Lambda = (a, b) => strlen(a) |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1614 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1615 v9.CheckScriptSuccess(lines) |
26482
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1616 enddef |
b115b552071f
patch 8.2.3771: Vim9: accessing freed memory when checking type
Bram Moolenaar <Bram@vim.org>
parents:
26470
diff
changeset
|
1617 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 " Default arg and varargs |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 def MyDefVarargs(one: string, two = 'foo', ...rest: list<string>): string |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1620 var res = one .. ',' .. two |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 for s in rest |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 res ..= ',' .. s |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 endfor |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 return res |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 def Test_call_def_varargs() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1628 assert_fails('g:MyDefVarargs()', 'E119:', '', 1, 'Test_call_def_varargs') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1629 g:MyDefVarargs('one')->assert_equal('one,foo') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1630 g:MyDefVarargs('one', 'two')->assert_equal('one,two') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1631 g:MyDefVarargs('one', 'two', 'three')->assert_equal('one,two,three') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1632 v9.CheckDefFailure(['g:MyDefVarargs("one", 22)'], |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22292
diff
changeset
|
1633 'E1013: Argument 2: type mismatch, expected string but got number') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1634 v9.CheckDefFailure(['g:MyDefVarargs("one", "two", 123)'], |
22296
006b8ab9d554
patch 8.2.1697: inconsistent capitalization of error messages
Bram Moolenaar <Bram@vim.org>
parents:
22292
diff
changeset
|
1635 'E1013: Argument 3: type mismatch, expected string but got number') |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1636 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1637 var lines =<< trim END |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1638 vim9script |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1639 def Func(...l: list<string>) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1640 echo l |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1641 enddef |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1642 Func('a', 'b', 'c') |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1643 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1644 v9.CheckScriptSuccess(lines) |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1645 |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1646 lines =<< trim END |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1647 vim9script |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1648 def Func(...l: list<string>) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1649 echo l |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1650 enddef |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1651 Func() |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1652 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1653 v9.CheckScriptSuccess(lines) |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1654 |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1655 lines =<< trim END |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1656 vim9script |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1657 def Func(...l: list<any>) |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1658 echo l |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1659 enddef |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1660 Func(0) |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1661 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1662 v9.CheckScriptSuccess(lines) |
24400
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1663 |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1664 lines =<< trim END |
62e978382fa0
patch 8.2.2740: Vim9: lambda with varargs doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
24398
diff
changeset
|
1665 vim9script |
22292
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1666 def Func(...l: any) |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1667 echo l |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1668 enddef |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1669 Func(0) |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1670 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1671 v9.CheckScriptFailure(lines, 'E1180:', 2) |
22292
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1672 |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1673 lines =<< trim END |
3515f341e8ac
patch 8.2.1695: Vim9: crash when using varargs type "any"
Bram Moolenaar <Bram@vim.org>
parents:
22284
diff
changeset
|
1674 vim9script |
22349
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1675 def Func(..._l: list<string>) |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1676 echo _l |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1677 enddef |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1678 Func('a', 'b', 'c') |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1679 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1680 v9.CheckScriptSuccess(lines) |
22349
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1681 |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1682 lines =<< trim END |
b66a2e046c2e
patch 8.2.1723: Vim9: Variable argument name cannot start with underscore
Bram Moolenaar <Bram@vim.org>
parents:
22339
diff
changeset
|
1683 vim9script |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1684 def Func(...l: list<string>) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1685 echo l |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1686 enddef |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1687 Func(1, 2, 3) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1688 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1689 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1690 |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1691 lines =<< trim END |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1692 vim9script |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1693 def Func(...l: list<string>) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1694 echo l |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1695 enddef |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1696 Func('a', 9) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1697 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1698 v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch') |
21481
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1699 |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1700 lines =<< trim END |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1701 vim9script |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1702 def Func(...l: list<string>) |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1703 echo l |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1704 enddef |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1705 Func(1, 'a') |
279b3415947f
patch 8.2.1291: Vim9: type of varargs items is not checked
Bram Moolenaar <Bram@vim.org>
parents:
21475
diff
changeset
|
1706 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1707 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch') |
23879
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1708 |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1709 lines =<< trim END |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1710 vim9script |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1711 def Func( # some comment |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1712 ...l = [] |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1713 ) |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1714 echo l |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1715 enddef |
9ddf1a537fc2
patch 8.2.2481: Vim9: confusing error when variable arguments have default
Bram Moolenaar <Bram@vim.org>
parents:
23808
diff
changeset
|
1716 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1717 v9.CheckScriptFailure(lines, 'E1160:') |
25543
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1718 |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1719 lines =<< trim END |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1720 vim9script |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1721 def DoIt() |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1722 g:Later('') |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1723 enddef |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1724 defcompile |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1725 def g:Later(...l: list<number>) |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1726 enddef |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1727 DoIt() |
a84e75d73fde
patch 8.2.3308: Vim9: no runtime check for argument type with varargs only
Bram Moolenaar <Bram@vim.org>
parents:
25489
diff
changeset
|
1728 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1729 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected number but got string') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1730 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1731 |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1732 let s:value = '' |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1733 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1734 def FuncOneDefArg(opt = 'text') |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1735 s:value = opt |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1736 enddef |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1737 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1738 def FuncTwoDefArg(nr = 123, opt = 'text'): string |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1739 return nr .. opt |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1740 enddef |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1741 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1742 def FuncVarargs(...arg: list<string>): string |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1743 return join(arg, ',') |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1744 enddef |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1745 |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1746 def Test_func_type_varargs() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1747 var RefDefArg: func(?string) |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1748 RefDefArg = g:FuncOneDefArg |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1749 RefDefArg() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1750 s:value->assert_equal('text') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1751 RefDefArg('some') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1752 s:value->assert_equal('some') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1753 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1754 var RefDef2Arg: func(?number, ?string): string |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1755 RefDef2Arg = g:FuncTwoDefArg |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1756 RefDef2Arg()->assert_equal('123text') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1757 RefDef2Arg(99)->assert_equal('99text') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1758 RefDef2Arg(77, 'some')->assert_equal('77some') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1759 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1760 v9.CheckDefFailure(['var RefWrong: func(string?)'], 'E1010:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1761 v9.CheckDefFailure(['var RefWrong: func(?string, string)'], 'E1007:') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1762 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1763 var RefVarargs: func(...list<string>): string |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1764 RefVarargs = g:FuncVarargs |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1765 RefVarargs()->assert_equal('') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1766 RefVarargs('one')->assert_equal('one') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1767 RefVarargs('one', 'two')->assert_equal('one,two') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1768 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1769 v9.CheckDefFailure(['var RefWrong: func(...list<string>, string)'], 'E110:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1770 v9.CheckDefFailure(['var RefWrong: func(...list<string>, ?string)'], 'E110:') |
19975
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1771 enddef |
4e8e0ce576af
patch 8.2.0543: Vim9: function with varargs does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
19946
diff
changeset
|
1772 |
19944
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1773 " Only varargs |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1774 def MyVarargsOnly(...args: list<string>): string |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1775 return join(args, ',') |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1776 enddef |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1777 |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1778 def Test_call_varargs_only() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1779 g:MyVarargsOnly()->assert_equal('') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1780 g:MyVarargsOnly('one')->assert_equal('one') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1781 g:MyVarargsOnly('one', 'two')->assert_equal('one,two') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1782 v9.CheckDefFailure(['g:MyVarargsOnly(1)'], 'E1013: Argument 1: type mismatch, expected string but got number') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1783 v9.CheckDefFailure(['g:MyVarargsOnly("one", 2)'], 'E1013: Argument 2: type mismatch, expected string but got number') |
19944
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1784 enddef |
3055cd26e139
patch 8.2.0528: Vim9: function arguments insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19942
diff
changeset
|
1785 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 def Test_using_var_as_arg() |
26845
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1787 var lines =<< trim END |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1788 def Func(x: number) |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1789 var x = 234 |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1790 enddef |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1791 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1792 v9.CheckDefFailure(lines, 'E1006:') |
26845
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1793 |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1794 lines =<< trim END |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1795 def Func(Ref: number) |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1796 def Ref() |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1797 enddef |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1798 enddef |
a6ccb6ec581c
patch 8.2.3951: Vim9: memory leak when text after a nested function
Bram Moolenaar <Bram@vim.org>
parents:
26792
diff
changeset
|
1799 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1800 v9.CheckDefFailure(lines, 'E1073:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1803 def s:DictArg(arg: dict<string>) |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1804 arg['key'] = 'value' |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1805 enddef |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1806 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1807 def s:ListArg(arg: list<string>) |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1808 arg[0] = 'value' |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1809 enddef |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1810 |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1811 def Test_assign_to_argument() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
1812 # works for dict and list |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1813 var d: dict<string> = {} |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1814 DictArg(d) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1815 d['key']->assert_equal('value') |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1816 var l: list<string> = [] |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1817 ListArg(l) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1818 l[0]->assert_equal('value') |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1819 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1820 v9.CheckScriptFailure(['def Func(arg: number)', 'arg = 3', 'enddef', 'defcompile'], 'E1090:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
1821 delfunc! g:Func |
20355
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1822 enddef |
fc2d76e0994c
patch 8.2.0733: Vim9: assigning to dict or list argument does not work
Bram Moolenaar <Bram@vim.org>
parents:
20303
diff
changeset
|
1823 |
22339
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1824 " These argument names are reserved in legacy functions. |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1825 def s:WithReservedNames(firstline: string, lastline: string): string |
22339
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1826 return firstline .. lastline |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1827 enddef |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1828 |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1829 def Test_argument_names() |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1830 assert_equal('OK', WithReservedNames('O', 'K')) |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1831 enddef |
56f674e7518c
patch 8.2.1718: Vim9: :def function disallows "firstline" for no good reason
Bram Moolenaar <Bram@vim.org>
parents:
22318
diff
changeset
|
1832 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 def Test_call_func_defined_later() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1834 g:DefinedLater('one')->assert_equal('one') |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
1835 assert_fails('NotDefined("one")', 'E117:', '', 2, 'Test_call_func_defined_later') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1838 func DefinedLater(arg) |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1839 return a:arg |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1840 endfunc |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1841 |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1842 def Test_call_funcref() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1843 g:SomeFunc('abc')->assert_equal(3) |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
1844 assert_fails('NotAFunc()', 'E117:', '', 2, 'Test_call_funcref') # comment after call |
26506
4a1d2abc2016
patch 8.2.3783: confusing error for using a variable as a function
Bram Moolenaar <Bram@vim.org>
parents:
26482
diff
changeset
|
1845 assert_fails('g:NotAFunc()', 'E1085:', '', 3, 'Test_call_funcref') |
21439
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1846 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1847 var lines =<< trim END |
21439
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1848 vim9script |
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1849 def RetNumber(): number |
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1850 return 123 |
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1851 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1852 var Funcref: func: number = function('RetNumber') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1853 Funcref()->assert_equal(123) |
21439
166c15374bda
patch 8.2.1270: Vim9: not skipping over function type declaration
Bram Moolenaar <Bram@vim.org>
parents:
21383
diff
changeset
|
1854 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1855 v9.CheckScriptSuccess(lines) |
21441
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1856 |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1857 lines =<< trim END |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1858 vim9script |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1859 def RetNumber(): number |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1860 return 123 |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1861 enddef |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1862 def Bar(F: func: number): number |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1863 return F() |
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1864 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1865 var Funcref = function('RetNumber') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1866 Bar(Funcref)->assert_equal(123) |
21441
78d97ee2c707
patch 8.2.1271: Vim9: Error for Funcref function argument type
Bram Moolenaar <Bram@vim.org>
parents:
21439
diff
changeset
|
1867 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1868 v9.CheckScriptSuccess(lines) |
21467
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1869 |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1870 lines =<< trim END |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1871 vim9script |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1872 def UseNumber(nr: number) |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1873 echo nr |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1874 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1875 var Funcref: func(number) = function('UseNumber') |
21467
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1876 Funcref(123) |
49072a858baf
patch 8.2.1284: Vim9: skipping over type includes following white space
Bram Moolenaar <Bram@vim.org>
parents:
21463
diff
changeset
|
1877 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1878 v9.CheckScriptSuccess(lines) |
21469
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1879 |
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1880 lines =<< trim END |
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1881 vim9script |
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1882 def UseNumber(nr: number) |
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1883 echo nr |
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1884 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1885 var Funcref: func(string) = function('UseNumber') |
21469
4d156aead799
patch 8.2.1285: Vim9: argument types are not checked on assignment
Bram Moolenaar <Bram@vim.org>
parents:
21467
diff
changeset
|
1886 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1887 v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(string) but got func(number)') |
21500
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1888 |
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1889 lines =<< trim END |
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1890 vim9script |
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1891 def EchoNr(nr = 34) |
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1892 g:echo = nr |
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1893 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1894 var Funcref: func(?number) = function('EchoNr') |
21500
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1895 Funcref() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1896 g:echo->assert_equal(34) |
21500
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1897 Funcref(123) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1898 g:echo->assert_equal(123) |
21500
574517d682cf
patch 8.2.1300: Vim9: optional argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21481
diff
changeset
|
1899 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1900 v9.CheckScriptSuccess(lines) |
21502
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1901 |
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1902 lines =<< trim END |
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1903 vim9script |
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1904 def EchoList(...l: list<number>) |
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1905 g:echo = l |
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1906 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1907 var Funcref: func(...list<number>) = function('EchoList') |
21502
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1908 Funcref() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1909 g:echo->assert_equal([]) |
21502
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1910 Funcref(1, 2, 3) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1911 g:echo->assert_equal([1, 2, 3]) |
21502
179697662a5a
patch 8.2.1301: Vim9: varargs argument type not parsed properly
Bram Moolenaar <Bram@vim.org>
parents:
21500
diff
changeset
|
1912 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1913 v9.CheckScriptSuccess(lines) |
21504
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1914 |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1915 lines =<< trim END |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1916 vim9script |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1917 def OptAndVar(nr: number, opt = 12, ...l: list<number>): number |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1918 g:optarg = opt |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1919 g:listarg = l |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1920 return nr |
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1921 enddef |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1922 var Funcref: func(number, ?number, ...list<number>): number = function('OptAndVar') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1923 Funcref(10)->assert_equal(10) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1924 g:optarg->assert_equal(12) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1925 g:listarg->assert_equal([]) |
21504
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1926 |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1927 Funcref(11, 22)->assert_equal(11) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1928 g:optarg->assert_equal(22) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1929 g:listarg->assert_equal([]) |
21504
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1930 |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1931 Funcref(17, 18, 1, 2, 3)->assert_equal(17) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1932 g:optarg->assert_equal(18) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
1933 g:listarg->assert_equal([1, 2, 3]) |
21504
e87a97868bbc
patch 8.2.1302: Vim9: varargs arg after optional arg does not work
Bram Moolenaar <Bram@vim.org>
parents:
21502
diff
changeset
|
1934 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1935 v9.CheckScriptSuccess(lines) |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1936 enddef |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1937 |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1938 let SomeFunc = function('len') |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1939 let NotAFunc = 'text' |
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1940 |
19993
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1941 def CombineFuncrefTypes() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
1942 # same arguments, different return type |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1943 var Ref1: func(bool): string |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1944 var Ref2: func(bool): number |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1945 var Ref3: func(bool): any |
19993
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1946 Ref3 = g:cond ? Ref1 : Ref2 |
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1947 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
1948 # different number of arguments |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1949 var Refa1: func(bool): number |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1950 var Refa2: func(bool, number): number |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1951 var Refa3: func: number |
19993
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1952 Refa3 = g:cond ? Refa1 : Refa2 |
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1953 |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
1954 # different argument types |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1955 var Refb1: func(bool, string): number |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1956 var Refb2: func(string, number): number |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
1957 var Refb3: func(any, any): number |
19993
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1958 Refb3 = g:cond ? Refb1 : Refb2 |
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1959 enddef |
efe864a7ce4f
patch 8.2.0552: Vim9: some errors not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
19985
diff
changeset
|
1960 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1961 def FuncWithForwardCall() |
20140
39a18a0df429
patch 8.2.0625: Vim9: confusing error when calling unknown function
Bram Moolenaar <Bram@vim.org>
parents:
20029
diff
changeset
|
1962 return g:DefinedEvenLater("yes") |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1963 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1964 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1965 def DefinedEvenLater(arg: string): string |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 return arg |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 def Test_error_in_nested_function() |
21353
fb8c8fcb7b60
patch 8.2.1227: Vim9: allowing both quoted and # comments is confusing
Bram Moolenaar <Bram@vim.org>
parents:
21347
diff
changeset
|
1970 # Error in called function requires unwinding the call stack. |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
1971 assert_fails('g:FuncWithForwardCall()', 'E1096:', '', 1, 'FuncWithForwardCall') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 |
26790
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1974 def Test_nested_function_with_nextcmd() |
26747
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1975 var lines =<< trim END |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1976 vim9script |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1977 # Define an outer function |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1978 def FirstFunction() |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1979 # Define an inner function |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1980 def SecondFunction() |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1981 # the function has a body, a double free is detected. |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1982 AAAAA |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1983 |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1984 # enddef followed by | or } followed by # one or more characters |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1985 enddef|BBBB |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1986 enddef |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1987 |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1988 # Compile all functions |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1989 defcompile |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1990 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
1991 v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') |
26747
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1992 enddef |
a8a4e1e7b111
patch 8.2.3902: Vim9: double free with nested :def function
Bram Moolenaar <Bram@vim.org>
parents:
26735
diff
changeset
|
1993 |
26790
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1994 def Test_nested_function_with_args_split() |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1995 var lines =<< trim END |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1996 vim9script |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1997 def FirstFunction() |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1998 def SecondFunction( |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
1999 ) |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2000 # had a double free if the right parenthesis of the nested function is |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2001 # on the next line |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2002 |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2003 enddef|BBBB |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2004 enddef |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2005 # Compile all functions |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2006 defcompile |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2007 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2008 v9.CheckScriptFailure(lines, 'E1173: Text found after enddef: BBBB') |
26792
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2009 |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2010 lines =<< trim END |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2011 vim9script |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2012 def FirstFunction() |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2013 func SecondFunction() |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2014 endfunc|BBBB |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2015 enddef |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2016 defcompile |
30d8377ea1b1
patch 8.2.3924: Vim9: no error if something follows :enddef
Bram Moolenaar <Bram@vim.org>
parents:
26790
diff
changeset
|
2017 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2018 v9.CheckScriptFailure(lines, 'E1173: Text found after endfunction: BBBB') |
26790
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2019 enddef |
83b35c75c21a
patch 8.2.3923: Vim9: double free with split argument list in nested function
Bram Moolenaar <Bram@vim.org>
parents:
26747
diff
changeset
|
2020 |
27022
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2021 def Test_error_in_function_args() |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2022 var lines =<< trim END |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2023 def FirstFunction() |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2024 def SecondFunction(J = |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2025 # Nois |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2026 # one |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2027 |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2028 enddef|BBBB |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2029 enddef |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2030 # Compile all functions |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2031 defcompile |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2032 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2033 v9.CheckScriptFailure(lines, 'E488:') |
27022
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2034 enddef |
eebbcc83fb75
patch 8.2.4040: keeping track of allocated lines is too complicated
Bram Moolenaar <Bram@vim.org>
parents:
26974
diff
changeset
|
2035 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2036 def Test_return_type_wrong() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2037 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2038 'def Func(): number', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2039 'return "a"', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2040 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2041 'defcompile'], 'expected number but got string') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2042 delfunc! g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2043 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2044 'def Func(): string', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2045 'return 1', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2046 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2047 'defcompile'], 'expected string but got number') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2048 delfunc! g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2049 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2050 'def Func(): void', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2051 'return "a"', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2052 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2053 'defcompile'], |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2054 'E1096: Returning a value in a function without a return type') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2055 delfunc! g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2056 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2057 'def Func()', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2058 'return "a"', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2059 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2060 'defcompile'], |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2061 'E1096: Returning a value in a function without a return type') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2062 delfunc! g:Func |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2063 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2064 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2065 'def Func(): number', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2066 'return', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2067 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2068 'defcompile'], 'E1003:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2069 delfunc! g:Func |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2070 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2071 v9.CheckScriptFailure([ |
25561
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2072 'def Func():number', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2073 'return 123', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2074 'enddef', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2075 'defcompile'], 'E1069:') |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2076 delfunc! g:Func |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2077 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2078 v9.CheckScriptFailure([ |
25561
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2079 'def Func() :number', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2080 'return 123', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2081 'enddef', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2082 'defcompile'], 'E1059:') |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2083 delfunc! g:Func |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2084 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2085 v9.CheckScriptFailure([ |
25561
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2086 'def Func() : number', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2087 'return 123', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2088 'enddef', |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2089 'defcompile'], 'E1059:') |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2090 delfunc! g:Func |
164cef0bc7ab
patch 8.2.3317: Vim9: No error for missing white space before return type
Bram Moolenaar <Bram@vim.org>
parents:
25543
diff
changeset
|
2091 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2092 v9.CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2093 delfunc! g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2094 v9.CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2095 delfunc! g:Func |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2096 v9.CheckScriptFailure(['def Func()', 'return 1'], 'E1057:') |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2097 delfunc! g:Func |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2098 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2099 v9.CheckScriptFailure([ |
21693
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2100 'vim9script', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2101 'def FuncB()', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2102 ' return 123', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2103 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2104 'def FuncA()', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2105 ' FuncB()', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2106 'enddef', |
4e4fd845553d
patch 8.2.1396: Vim9: no error for unexpectedly returning a value
Bram Moolenaar <Bram@vim.org>
parents:
21689
diff
changeset
|
2107 'defcompile'], 'E1096:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2108 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2109 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2110 def Test_arg_type_wrong() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2111 v9.CheckScriptFailure(['def Func3(items: list)', 'echo "a"', 'enddef'], 'E1008: Missing <type>') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2112 v9.CheckScriptFailure(['def Func4(...)', 'echo "a"', 'enddef'], 'E1055: Missing name after ...') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2113 v9.CheckScriptFailure(['def Func5(items:string)', 'echo "a"'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2114 v9.CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2115 v9.CheckScriptFailure(['def Func6(...x:list<number>)', 'echo "a"', 'enddef'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2116 v9.CheckScriptFailure(['def Func7(...x: int)', 'echo "a"', 'enddef'], 'E1010:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2117 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2118 |
24371
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2119 def Test_white_space_before_comma() |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2120 var lines =<< trim END |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2121 vim9script |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2122 def Func(a: number , b: number) |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2123 enddef |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2124 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2125 v9.CheckScriptFailure(lines, 'E1068:') |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24651
diff
changeset
|
2126 call assert_fails('vim9cmd echo stridx("a" .. "b" , "a")', 'E1068:') |
24371
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2127 enddef |
2b4883926a24
patch 8.2.2726: confusing error message with white space before comma
Bram Moolenaar <Bram@vim.org>
parents:
24369
diff
changeset
|
2128 |
24069
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2129 def Test_white_space_after_comma() |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2130 var lines =<< trim END |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2131 vim9script |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2132 def Func(a: number,b: number) |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2133 enddef |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2134 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2135 v9.CheckScriptFailure(lines, 'E1069:') |
24069
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2136 |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2137 # OK in legacy function |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2138 lines =<< trim END |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2139 vim9script |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2140 func Func(a,b) |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2141 endfunc |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2142 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2143 v9.CheckScriptSuccess(lines) |
24069
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2144 enddef |
324408c61b20
patch 8.2.2576: Vim9: defining a :func function checks for white space
Bram Moolenaar <Bram@vim.org>
parents:
24065
diff
changeset
|
2145 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2146 def Test_vim9script_call() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2147 var lines =<< trim END |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2148 vim9script |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2149 var name = '' |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2150 def MyFunc(arg: string) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2151 name = arg |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2152 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2153 MyFunc('foobar') |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2154 name->assert_equal('foobar') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2155 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2156 var str = 'barfoo' |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2157 str->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2158 name->assert_equal('barfoo') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2159 |
20945
0653b9b72091
patch 8.2.1024: Vim9: no error for using "let g:var = val"
Bram Moolenaar <Bram@vim.org>
parents:
20909
diff
changeset
|
2160 g:value = 'value' |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2161 g:value->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2162 name->assert_equal('value') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2163 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2164 var listvar = [] |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2165 def ListFunc(arg: list<number>) |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2166 listvar = arg |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2167 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2168 [1, 2, 3]->ListFunc() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2169 listvar->assert_equal([1, 2, 3]) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2170 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2171 var dictvar = {} |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2172 def DictFunc(arg: dict<number>) |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2173 dictvar = arg |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2174 enddef |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2175 {a: 1, b: 2}->DictFunc() |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2176 dictvar->assert_equal({a: 1, b: 2}) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2177 def CompiledDict() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2178 {a: 3, b: 4}->DictFunc() |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2179 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2180 CompiledDict() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2181 dictvar->assert_equal({a: 3, b: 4}) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2182 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2183 {a: 3, b: 4}->DictFunc() |
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2184 dictvar->assert_equal({a: 3, b: 4}) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2185 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2186 ('text')->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2187 name->assert_equal('text') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2188 ("some")->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2189 name->assert_equal('some') |
21118
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2190 |
21475
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2191 # line starting with single quote is not a mark |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2192 # line starting with double quote can be a method call |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2193 'asdfasdf'->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2194 name->assert_equal('asdfasdf') |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2195 "xyz"->MyFunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2196 name->assert_equal('xyz') |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2197 |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2198 def UseString() |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2199 'xyork'->MyFunc() |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2200 enddef |
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2201 UseString() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2202 name->assert_equal('xyork') |
21335
af3663df42bf
patch 8.2.1218: Vim9: cannot use 'text'->func()
Bram Moolenaar <Bram@vim.org>
parents:
21303
diff
changeset
|
2203 |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2204 def UseString2() |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2205 "knife"->MyFunc() |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2206 enddef |
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2207 UseString2() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2208 name->assert_equal('knife') |
21544
6c67c86a202a
patch 8.2.1322: Vim9: method on double quoted string doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
21504
diff
changeset
|
2209 |
21475
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2210 # prepending a colon makes it a mark |
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2211 new |
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2212 setline(1, ['aaa', 'bbb', 'ccc']) |
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2213 normal! 3Gmt1G |
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2214 :'t |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2215 getcurpos()[1]->assert_equal(3) |
21475
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2216 bwipe! |
eec2d2120cde
patch 8.2.1288: Vim9: cannot use mark in range
Bram Moolenaar <Bram@vim.org>
parents:
21469
diff
changeset
|
2217 |
21118
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2218 MyFunc( |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2219 'continued' |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2220 ) |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2221 assert_equal('continued', |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2222 name |
21118
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2223 ) |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2224 |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2225 call MyFunc( |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2226 'more' |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2227 .. |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2228 'lines' |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2229 ) |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2230 assert_equal( |
b0baa80cb53f
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Bram Moolenaar <Bram@vim.org>
parents:
21089
diff
changeset
|
2231 'morelines', |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2232 name) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2233 END |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2234 writefile(lines, 'Xcall.vim') |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2235 source Xcall.vim |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2236 delete('Xcall.vim') |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2237 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2238 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2239 def Test_vim9script_call_fail_decl() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2240 var lines =<< trim END |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2241 vim9script |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2242 var name = '' |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2243 def MyFunc(arg: string) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2244 var name = 123 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2245 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20433
diff
changeset
|
2246 defcompile |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2247 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2248 v9.CheckScriptFailure(lines, 'E1054:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2249 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2250 |
21383
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2251 def Test_vim9script_call_fail_type() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2252 var lines =<< trim END |
21383
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2253 vim9script |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2254 def MyFunc(arg: string) |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2255 echo arg |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2256 enddef |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2257 MyFunc(1234) |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2258 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2259 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') |
21383
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2260 enddef |
f25d007f90ac
patch 8.2.1242: Vim9: no error if calling a function with wrong type
Bram Moolenaar <Bram@vim.org>
parents:
21353
diff
changeset
|
2261 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2262 def Test_vim9script_call_fail_const() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2263 var lines =<< trim END |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2264 vim9script |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2265 const var = '' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2266 def MyFunc(arg: string) |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2267 var = 'asdf' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2268 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20433
diff
changeset
|
2269 defcompile |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2270 END |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2271 writefile(lines, 'Xcall_const.vim') |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
2272 assert_fails('source Xcall_const.vim', 'E46:', '', 1, 'MyFunc') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2273 delete('Xcall_const.vim') |
23295
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2274 |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2275 lines =<< trim END |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2276 const g:Aconst = 77 |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2277 def Change() |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2278 # comment |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2279 g:Aconst = 99 |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2280 enddef |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2281 call Change() |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2282 unlet g:Aconst |
d9ae7dd3a0f2
patch 8.2.2193: Vim9: can change constant in :def function
Bram Moolenaar <Bram@vim.org>
parents:
23291
diff
changeset
|
2283 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2284 v9.CheckScriptFailure(lines, 'E741: Value is locked: Aconst', 2) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2285 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2286 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2287 " Test that inside :function a Python function can be defined, :def is not |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2288 " recognized. |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2289 func Test_function_python() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2290 CheckFeature python3 |
22437
7bd80999ea21
patch 8.2.1767: Vim9: test fails with python support
Bram Moolenaar <Bram@vim.org>
parents:
22435
diff
changeset
|
2291 let py = 'python3' |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2292 execute py "<< EOF" |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2293 def do_something(): |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2294 return 1 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2295 EOF |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2296 endfunc |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2297 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2298 def Test_delfunc() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2299 var lines =<< trim END |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2300 vim9script |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
2301 def g:GoneSoon() |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2302 echo 'hello' |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2303 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2304 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2305 def CallGoneSoon() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2306 g:GoneSoon() |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2307 enddef |
20528
489cb75c76b6
patch 8.2.0818: Vim9: using a discovery phase doesn't work well
Bram Moolenaar <Bram@vim.org>
parents:
20433
diff
changeset
|
2308 defcompile |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2309 |
20189
63cc54100ae4
patch 8.2.0650: Vim9: script function can be deleted
Bram Moolenaar <Bram@vim.org>
parents:
20142
diff
changeset
|
2310 delfunc g:GoneSoon |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2311 CallGoneSoon() |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2312 END |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2313 writefile(lines, 'XToDelFunc') |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
2314 assert_fails('so XToDelFunc', 'E933:', '', 1, 'CallGoneSoon') |
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
2315 assert_fails('so XToDelFunc', 'E933:', '', 1, 'CallGoneSoon') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2316 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2317 delete('XToDelFunc') |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2318 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2319 |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2320 func Test_free_dict_while_in_funcstack() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2321 " relies on the sleep command |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2322 CheckUnix |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2323 call Run_Test_free_dict_while_in_funcstack() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2324 endfunc |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2325 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2326 def Run_Test_free_dict_while_in_funcstack() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2327 # this was freeing the TermRun() default argument dictionary while it was |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2328 # still referenced in a funcstack_T |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2329 var lines =<< trim END |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2330 vim9script |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2331 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2332 &updatetime = 400 |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2333 def TermRun(_ = {}) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2334 def Post() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2335 enddef |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2336 def Exec() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2337 term_start('sleep 1', { |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2338 term_finish: 'close', |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2339 exit_cb: (_, _) => Post(), |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2340 }) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2341 enddef |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2342 Exec() |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2343 enddef |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2344 nnoremap <F4> <Cmd>call <SID>TermRun()<CR> |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2345 timer_start(100, (_) => feedkeys("\<F4>")) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2346 timer_start(1000, (_) => feedkeys("\<F4>")) |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2347 sleep 1500m |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2348 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2349 v9.CheckScriptSuccess(lines) |
26560
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2350 nunmap <F4> |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2351 set updatetime& |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2352 enddef |
454a1c9ef797
patch 8.2.3809: Vim9: crash when garbage collecting a nested partial
Bram Moolenaar <Bram@vim.org>
parents:
26538
diff
changeset
|
2353 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2354 def Test_redef_failure() |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22139
diff
changeset
|
2355 writefile(['def Func0(): string', 'return "Func0"', 'enddef'], 'Xdef') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2356 so Xdef |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22139
diff
changeset
|
2357 writefile(['def Func1(): string', 'return "Func1"', 'enddef'], 'Xdef') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2358 so Xdef |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22139
diff
changeset
|
2359 writefile(['def! Func0(): string', 'enddef', 'defcompile'], 'Xdef') |
22163
b6d36f0b4f03
patch 8.2.1631: test_fails() does not check the context of the line number
Bram Moolenaar <Bram@vim.org>
parents:
22159
diff
changeset
|
2360 assert_fails('so Xdef', 'E1027:', '', 1, 'Func0') |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22139
diff
changeset
|
2361 writefile(['def Func2(): string', 'return "Func2"', 'enddef'], 'Xdef') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2362 so Xdef |
22147
d55008685870
patch 8.2.1623: Vim9: using :call where it is not needed
Bram Moolenaar <Bram@vim.org>
parents:
22139
diff
changeset
|
2363 delete('Xdef') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2364 |
24404
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
2365 assert_fails('g:Func0()', 'E1091:') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2366 g:Func1()->assert_equal('Func1') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2367 g:Func2()->assert_equal('Func2') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2368 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2369 delfunc! Func0 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2370 delfunc! Func1 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2371 delfunc! Func2 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2372 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2373 |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2374 def Test_vim9script_func() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2375 var lines =<< trim END |
20142
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2376 vim9script |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2377 func Func(arg) |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2378 echo a:arg |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2379 endfunc |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2380 Func('text') |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2381 END |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2382 writefile(lines, 'XVim9Func') |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2383 so XVim9Func |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2384 |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2385 delete('XVim9Func') |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2386 enddef |
fe8d0a4344df
patch 8.2.0626: Vim9: wrong syntax of function in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
20140
diff
changeset
|
2387 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2388 let s:funcResult = 0 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2389 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2390 def FuncNoArgNoRet() |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2391 s:funcResult = 11 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2392 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2393 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2394 def FuncNoArgRetNumber(): number |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2395 s:funcResult = 22 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2396 return 1234 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2397 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2398 |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2399 def FuncNoArgRetString(): string |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2400 s:funcResult = 45 |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2401 return 'text' |
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2402 enddef |
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2403 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2404 def FuncOneArgNoRet(arg: number) |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2405 s:funcResult = arg |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2406 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2407 |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2408 def FuncOneArgRetNumber(arg: number): number |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2409 s:funcResult = arg |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2410 return arg |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2411 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2412 |
19985
f863aa96cae5
patch 8.2.0548: Vim9: not all possible func type errors tested
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
2413 def FuncTwoArgNoRet(one: bool, two: number) |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2414 s:funcResult = two |
19985
f863aa96cae5
patch 8.2.0548: Vim9: not all possible func type errors tested
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
2415 enddef |
f863aa96cae5
patch 8.2.0548: Vim9: not all possible func type errors tested
Bram Moolenaar <Bram@vim.org>
parents:
19975
diff
changeset
|
2416 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2417 def s:FuncOneArgRetString(arg: string): string |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2418 return arg |
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2419 enddef |
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2420 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2421 def s:FuncOneArgRetAny(arg: any): any |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2422 return arg |
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2423 enddef |
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2424 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2425 def Test_func_type() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2426 var Ref1: func() |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2427 s:funcResult = 0 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2428 Ref1 = g:FuncNoArgNoRet |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2429 Ref1() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2430 s:funcResult->assert_equal(11) |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2431 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2432 var Ref2: func |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2433 s:funcResult = 0 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2434 Ref2 = g:FuncNoArgNoRet |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2435 Ref2() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2436 s:funcResult->assert_equal(11) |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2437 |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2438 s:funcResult = 0 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2439 Ref2 = g:FuncOneArgNoRet |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2440 Ref2(12) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2441 s:funcResult->assert_equal(12) |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2442 |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2443 s:funcResult = 0 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2444 Ref2 = g:FuncNoArgRetNumber |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2445 Ref2()->assert_equal(1234) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2446 s:funcResult->assert_equal(22) |
19922
1f42c49c3d29
patch 8.2.0517: Vim9: cannot separate "func" and "func(): void"
Bram Moolenaar <Bram@vim.org>
parents:
19912
diff
changeset
|
2447 |
21921
e420f3cf60e2
patch 8.2.1510: using "var" in :def function may refer to legacy script var
Bram Moolenaar <Bram@vim.org>
parents:
21913
diff
changeset
|
2448 s:funcResult = 0 |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2449 Ref2 = g:FuncOneArgRetNumber |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2450 Ref2(13)->assert_equal(13) |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2451 s:funcResult->assert_equal(13) |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2452 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2453 |
21162
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2454 def Test_repeat_return_type() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2455 var res = 0 |
21162
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2456 for n in repeat([1], 3) |
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2457 res += n |
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2458 endfor |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2459 res->assert_equal(3) |
21164
4a190861f0cc
patch 8.2.1133: Vim9: return type of add() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21162
diff
changeset
|
2460 |
4a190861f0cc
patch 8.2.1133: Vim9: return type of add() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21162
diff
changeset
|
2461 res = 0 |
4a190861f0cc
patch 8.2.1133: Vim9: return type of add() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21162
diff
changeset
|
2462 for n in add([1, 2], 3) |
4a190861f0cc
patch 8.2.1133: Vim9: return type of add() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21162
diff
changeset
|
2463 res += n |
4a190861f0cc
patch 8.2.1133: Vim9: return type of add() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21162
diff
changeset
|
2464 endfor |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2465 res->assert_equal(6) |
21162
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2466 enddef |
3158cc2384cc
patch 8.2.1132: Vim9: return type of repeat() is not specific enough
Bram Moolenaar <Bram@vim.org>
parents:
21160
diff
changeset
|
2467 |
21170
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2468 def Test_argv_return_type() |
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2469 next fileone filetwo |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2470 var res = '' |
21170
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2471 for name in argv() |
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2472 res ..= name |
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2473 endfor |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2474 res->assert_equal('fileonefiletwo') |
21170
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2475 enddef |
8c494353c6bc
patch 8.2.1136: Vim9: return type of argv() is always any
Bram Moolenaar <Bram@vim.org>
parents:
21164
diff
changeset
|
2476 |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2477 def Test_func_type_part() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2478 var RefVoid: func: void |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2479 RefVoid = g:FuncNoArgNoRet |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2480 RefVoid = g:FuncOneArgNoRet |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2481 v9.CheckDefFailure(['var RefVoid: func: void', 'RefVoid = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...) but got func(): number') |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2482 v9.CheckDefFailure(['var RefVoid: func: void', 'RefVoid = g:FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...) but got func(): string') |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2483 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2484 var RefAny: func(): any |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2485 RefAny = g:FuncNoArgRetNumber |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2486 RefAny = g:FuncNoArgRetString |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2487 v9.CheckDefFailure(['var RefAny: func(): any', 'RefAny = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func()') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2488 v9.CheckDefFailure(['var RefAny: func(): any', 'RefAny = g:FuncOneArgNoRet'], 'E1012: Type mismatch; expected func(): any but got func(number)') |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2489 |
22498
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2490 var RefAnyNoArgs: func: any = RefAny |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2491 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2492 var RefNr: func: number |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2493 RefNr = g:FuncNoArgRetNumber |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2494 RefNr = g:FuncOneArgRetNumber |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2495 v9.CheckDefFailure(['var RefNr: func: number', 'RefNr = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): number but got func()') |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2496 v9.CheckDefFailure(['var RefNr: func: number', 'RefNr = g:FuncNoArgRetString'], 'E1012: Type mismatch; expected func(...): number but got func(): string') |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2497 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2498 var RefStr: func: string |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2499 RefStr = g:FuncNoArgRetString |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2500 RefStr = FuncOneArgRetString |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2501 v9.CheckDefFailure(['var RefStr: func: string', 'RefStr = g:FuncNoArgNoRet'], 'E1012: Type mismatch; expected func(...): string but got func()') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2502 v9.CheckDefFailure(['var RefStr: func: string', 'RefStr = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func(...): string but got func(): number') |
19942
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2503 enddef |
b471038ec3ea
patch 8.2.0527: Vim9: function types insufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
2504 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2505 def Test_func_type_fails() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2506 v9.CheckDefFailure(['var ref1: func()'], 'E704:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2507 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2508 v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncNoArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(): number') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2509 v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncOneArgNoRet'], 'E1012: Type mismatch; expected func() but got func(number)') |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
2510 v9.CheckDefFailure(['var Ref1: func()', 'Ref1 = g:FuncOneArgRetNumber'], 'E1012: Type mismatch; expected func() but got func(number): number') |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2511 v9.CheckDefFailure(['var Ref1: func(bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(bool) but got func(bool, number)') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2512 v9.CheckDefFailure(['var Ref1: func(?bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(?bool) but got func(bool, number)') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2513 v9.CheckDefFailure(['var Ref1: func(...bool)', 'Ref1 = g:FuncTwoArgNoRet'], 'E1012: Type mismatch; expected func(...bool) but got func(bool, number)') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2514 |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2515 v9.CheckDefFailure(['var RefWrong: func(string ,number)'], 'E1068:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2516 v9.CheckDefFailure(['var RefWrong: func(string,number)'], 'E1069:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2517 v9.CheckDefFailure(['var RefWrong: func(bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool, bool)'], 'E1005:') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2518 v9.CheckDefFailure(['var RefWrong: func(bool):string'], 'E1069:') |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2519 enddef |
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2520 |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2521 def Test_func_return_type() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2522 var nr: number |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2523 nr = g:FuncNoArgRetNumber() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2524 nr->assert_equal(1234) |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2525 |
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2526 nr = FuncOneArgRetAny(122) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2527 nr->assert_equal(122) |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2528 |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2529 var str: string |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2530 str = FuncOneArgRetAny('yes') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2531 str->assert_equal('yes') |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2532 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2533 v9.CheckDefFailure(['var str: string', 'str = g:FuncNoArgRetNumber()'], 'E1012: Type mismatch; expected string but got number') |
19926
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2534 enddef |
d286bfc44149
patch 8.2.0519: Vim9: return type not properly checked
Bram Moolenaar <Bram@vim.org>
parents:
19922
diff
changeset
|
2535 |
22498
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2536 def Test_func_common_type() |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2537 def FuncOne(n: number): number |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2538 return n |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2539 enddef |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2540 def FuncTwo(s: string): number |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2541 return len(s) |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2542 enddef |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2543 def FuncThree(n: number, s: string): number |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2544 return n + len(s) |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2545 enddef |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2546 var list = [FuncOne, FuncTwo, FuncThree] |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2547 assert_equal(8, list[0](8)) |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2548 assert_equal(4, list[1]('word')) |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2549 assert_equal(7, list[2](3, 'word')) |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2550 enddef |
04a9b1399d8e
patch 8.2.1797: Vim9: some parts of the code not tested
Bram Moolenaar <Bram@vim.org>
parents:
22496
diff
changeset
|
2551 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2552 def s:MultiLine( |
20015
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2553 arg1: string, |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2554 arg2 = 1234, |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2555 ...rest: list<string> |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2556 ): string |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2557 return arg1 .. arg2 .. join(rest, '-') |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2558 enddef |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2559 |
20023
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2560 def MultiLineComment( |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2561 arg1: string, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2562 arg2 = 1234, # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2563 ...rest: list<string> # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2564 ): string # comment |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2565 return arg1 .. arg2 .. join(rest, '-') |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2566 enddef |
c85d4e173cc9
patch 8.2.0567: Vim9: cannot put comments halfway expressions
Bram Moolenaar <Bram@vim.org>
parents:
20017
diff
changeset
|
2567 |
20015
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2568 def Test_multiline() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2569 MultiLine('text')->assert_equal('text1234') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2570 MultiLine('text', 777)->assert_equal('text777') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2571 MultiLine('text', 777, 'one')->assert_equal('text777one') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2572 MultiLine('text', 777, 'one', 'two')->assert_equal('text777one-two') |
20015
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2573 enddef |
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2574 |
20017
ee823254dda5
patch 8.2.0564: Vim9: calling a def function from non-vim9 may fail
Bram Moolenaar <Bram@vim.org>
parents:
20015
diff
changeset
|
2575 func Test_multiline_not_vim9() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2576 call s:MultiLine('text')->assert_equal('text1234') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2577 call s:MultiLine('text', 777)->assert_equal('text777') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2578 call s:MultiLine('text', 777, 'one')->assert_equal('text777one') |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2579 call s:MultiLine('text', 777, 'one', 'two')->assert_equal('text777one-two') |
20017
ee823254dda5
patch 8.2.0564: Vim9: calling a def function from non-vim9 may fail
Bram Moolenaar <Bram@vim.org>
parents:
20015
diff
changeset
|
2580 endfunc |
ee823254dda5
patch 8.2.0564: Vim9: calling a def function from non-vim9 may fail
Bram Moolenaar <Bram@vim.org>
parents:
20015
diff
changeset
|
2581 |
20015
c001ee73519a
patch 8.2.0563: Vim9: cannot split a function line
Bram Moolenaar <Bram@vim.org>
parents:
19993
diff
changeset
|
2582 |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2583 " When using CheckScriptFailure() for the below test, E1010 is generated instead |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2584 " of E1056. |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2585 func Test_E1056_1059() |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2586 let caught_1056 = 0 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2587 try |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2588 def F(): |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2589 return 1 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2590 enddef |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2591 catch /E1056:/ |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2592 let caught_1056 = 1 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2593 endtry |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2594 eval caught_1056->assert_equal(1) |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2595 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2596 let caught_1059 = 0 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2597 try |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2598 def F5(items : list) |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2599 echo 'a' |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2600 enddef |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2601 catch /E1059:/ |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2602 let caught_1059 = 1 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2603 endtry |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2604 eval caught_1059->assert_equal(1) |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19926
diff
changeset
|
2605 endfunc |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2606 |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2607 func DelMe() |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2608 echo 'DelMe' |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2609 endfunc |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2610 |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2611 def Test_error_reporting() |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2612 # comment lines at the start of the function |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2613 var lines =<< trim END |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2614 " comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2615 def Func() |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2616 # comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2617 # comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2618 invalid |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2619 enddef |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2620 defcompile |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2621 END |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22236
diff
changeset
|
2622 writefile(lines, 'Xdef') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2623 try |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2624 source Xdef |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2625 assert_report('should have failed') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2626 catch /E476:/ |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2627 v:exception->assert_match('Invalid command: invalid') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2628 v:throwpoint->assert_match(', line 3$') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2629 endtry |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2630 delfunc! g:Func |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2631 |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2632 # comment lines after the start of the function |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2633 lines =<< trim END |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2634 " comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2635 def Func() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2636 var x = 1234 |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2637 # comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2638 # comment |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2639 invalid |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2640 enddef |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2641 defcompile |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2642 END |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22236
diff
changeset
|
2643 writefile(lines, 'Xdef') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2644 try |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2645 source Xdef |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2646 assert_report('should have failed') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2647 catch /E476:/ |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2648 v:exception->assert_match('Invalid command: invalid') |
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2649 v:throwpoint->assert_match(', line 4$') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2650 endtry |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2651 delfunc! g:Func |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2652 |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2653 lines =<< trim END |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2654 vim9script |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2655 def Func() |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
2656 var db = {foo: 1, bar: 2} |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2657 # comment |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2658 var x = db.asdf |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2659 enddef |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2660 defcompile |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2661 Func() |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2662 END |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22236
diff
changeset
|
2663 writefile(lines, 'Xdef') |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2664 try |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2665 source Xdef |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2666 assert_report('should have failed') |
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2667 catch /E716:/ |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2668 v:throwpoint->assert_match('_Func, line 3$') |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2669 endtry |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
2670 delfunc! g:Func |
21793
0706bd071fa3
patch 8.2.1446: Vim9: line number in error message is not correct
Bram Moolenaar <Bram@vim.org>
parents:
21759
diff
changeset
|
2671 |
22264
e0a4d029cb87
patch 8.2.1681: Vim9: unnessary :call commands in tests
Bram Moolenaar <Bram@vim.org>
parents:
22236
diff
changeset
|
2672 delete('Xdef') |
21685
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2673 enddef |
26a4b53c4587
patch 8.2.1392: Vim9: line number incorrect after skipping over comment lines
Bram Moolenaar <Bram@vim.org>
parents:
21660
diff
changeset
|
2674 |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2675 def Test_deleted_function() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2676 v9.CheckDefExecFailure([ |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2677 'var RefMe: func = function("g:DelMe")', |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2678 'delfunc g:DelMe', |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2679 'echo RefMe()'], 'E117:') |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2680 enddef |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2681 |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2682 def Test_unknown_function() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2683 v9.CheckDefExecFailure([ |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2684 'var Ref: func = function("NotExist")', |
21265
6a4806e326dd
patch 8.2.1183: assert_fails() checks the last error message
Bram Moolenaar <Bram@vim.org>
parents:
21263
diff
changeset
|
2685 'delfunc g:NotExist'], 'E700:') |
20287
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2686 enddef |
ce1b73835822
patch 8.2.0699: Vim9: not all errors tested
Bram Moolenaar <Bram@vim.org>
parents:
20281
diff
changeset
|
2687 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2688 def s:RefFunc(Ref: func(any): any): string |
20244
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2689 return Ref('more') |
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2690 enddef |
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2691 |
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2692 def Test_closure_simple() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2693 var local = 'some ' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2694 RefFunc((s) => local .. s)->assert_equal('some more') |
20244
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2695 enddef |
23d75968ca5e
patch 8.2.0677: Vim9: no support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20189
diff
changeset
|
2696 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2697 def s:MakeRef() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2698 var local = 'some ' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2699 g:Ref = (s) => local .. s |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2700 enddef |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2701 |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2702 def Test_closure_ref_after_return() |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2703 MakeRef() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2704 g:Ref('thing')->assert_equal('some thing') |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2705 unlet g:Ref |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2706 enddef |
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2707 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2708 def s:MakeTwoRefs() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2709 var local = ['some'] |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2710 g:Extend = (s) => local->add(s) |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2711 g:Read = () => local |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2712 enddef |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2713 |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2714 def Test_closure_two_refs() |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2715 MakeTwoRefs() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2716 join(g:Read(), ' ')->assert_equal('some') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2717 g:Extend('more') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2718 join(g:Read(), ' ')->assert_equal('some more') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2719 g:Extend('even') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2720 join(g:Read(), ' ')->assert_equal('some more even') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2721 |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2722 unlet g:Extend |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2723 unlet g:Read |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2724 enddef |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2725 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2726 def s:ReadRef(Ref: func(): list<string>): string |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2727 return join(Ref(), ' ') |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2728 enddef |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2729 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2730 def s:ExtendRef(Ref: func(string): list<string>, add: string) |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2731 Ref(add) |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2732 enddef |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2733 |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2734 def Test_closure_two_indirect_refs() |
20257
683c2da4982b
patch 8.2.0684: Vim9: memory leak when using lambda
Bram Moolenaar <Bram@vim.org>
parents:
20255
diff
changeset
|
2735 MakeTwoRefs() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2736 ReadRef(g:Read)->assert_equal('some') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2737 ExtendRef(g:Extend, 'more') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2738 ReadRef(g:Read)->assert_equal('some more') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2739 ExtendRef(g:Extend, 'even') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2740 ReadRef(g:Read)->assert_equal('some more even') |
20255
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2741 |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2742 unlet g:Extend |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2743 unlet g:Read |
aac52c32a91f
patch 8.2.0683: Vim9: parsing type does not always work
Bram Moolenaar <Bram@vim.org>
parents:
20253
diff
changeset
|
2744 enddef |
20247
e46e72aaff74
patch 8.2.0679: Vim9: incomplete support for closures
Bram Moolenaar <Bram@vim.org>
parents:
20244
diff
changeset
|
2745 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2746 def s:MakeArgRefs(theArg: string) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2747 var local = 'loc_val' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2748 g:UseArg = (s) => theArg .. '/' .. local .. '/' .. s |
20275
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2749 enddef |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2750 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2751 def s:MakeArgRefsVarargs(theArg: string, ...rest: list<string>) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2752 var local = 'the_loc' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2753 g:UseVararg = (s) => theArg .. '/' .. local .. '/' .. s .. '/' .. join(rest) |
20275
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2754 enddef |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2755 |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2756 def Test_closure_using_argument() |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2757 MakeArgRefs('arg_val') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2758 g:UseArg('call_val')->assert_equal('arg_val/loc_val/call_val') |
20275
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2759 |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2760 MakeArgRefsVarargs('arg_val', 'one', 'two') |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2761 g:UseVararg('call_val')->assert_equal('arg_val/the_loc/call_val/one two') |
20275
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2762 |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2763 unlet g:UseArg |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2764 unlet g:UseVararg |
23923
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2765 |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2766 var lines =<< trim END |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2767 vim9script |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2768 def Test(Fun: func(number): number): list<number> |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2769 return map([1, 2, 3], (_, i) => Fun(i)) |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2770 enddef |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2771 def Inc(nr: number): number |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2772 return nr + 2 |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2773 enddef |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2774 assert_equal([3, 4, 5], Test(Inc)) |
be36288235af
patch 8.2.2504: Vim9: crash when using an argument from a closure
Bram Moolenaar <Bram@vim.org>
parents:
23879
diff
changeset
|
2775 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2776 v9.CheckScriptSuccess(lines) |
20275
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2777 enddef |
350bb78345ba
patch 8.2.0693: closure using argument not tested
Bram Moolenaar <Bram@vim.org>
parents:
20257
diff
changeset
|
2778 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2779 def s:MakeGetAndAppendRefs() |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2780 var local = 'a' |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2781 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2782 def Append(arg: string) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2783 local ..= arg |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2784 enddef |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2785 g:Append = Append |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2786 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2787 def Get(): string |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2788 return local |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2789 enddef |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2790 g:Get = Get |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2791 enddef |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2792 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2793 def Test_closure_append_get() |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2794 MakeGetAndAppendRefs() |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2795 g:Get()->assert_equal('a') |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2796 g:Append('-b') |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2797 g:Get()->assert_equal('a-b') |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2798 g:Append('-c') |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2799 g:Get()->assert_equal('a-b-c') |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2800 |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2801 unlet g:Append |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2802 unlet g:Get |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2803 enddef |
20295
bc2c9ea94ec1
patch 8.2.0703: Vim9: closure cannot store value in outer context
Bram Moolenaar <Bram@vim.org>
parents:
20287
diff
changeset
|
2804 |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2805 def Test_nested_closure() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2806 var local = 'text' |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2807 def Closure(arg: string): string |
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2808 return local .. arg |
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2809 enddef |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2810 Closure('!!!')->assert_equal('text!!!') |
20279
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2811 enddef |
49b50843e725
patch 8.2.0695: Vim9: cannot define a function inside a function
Bram Moolenaar <Bram@vim.org>
parents:
20275
diff
changeset
|
2812 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2813 func s:GetResult(Ref) |
20433
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2814 return a:Ref('some') |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2815 endfunc |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2816 |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2817 def Test_call_closure_not_compiled() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2818 var text = 'text' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2819 g:Ref = (s) => s .. text |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
2820 GetResult(g:Ref)->assert_equal('sometext') |
20433
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2821 enddef |
5950284a517f
patch 8.2.0771: Vim9: cannot call a compiled closure from not compiled code
Bram Moolenaar <Bram@vim.org>
parents:
20355
diff
changeset
|
2822 |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2823 def Test_double_closure_fails() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2824 var lines =<< trim END |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2825 vim9script |
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2826 def Func() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2827 var name = 0 |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2828 for i in range(2) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2829 timer_start(0, () => name) |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2830 endfor |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2831 enddef |
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2832 Func() |
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2833 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2834 v9.CheckScriptSuccess(lines) |
22314
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2835 enddef |
41e118669df3
patch 8.2.1706: Vim9: crash after running into the "Multiple closures" error
Bram Moolenaar <Bram@vim.org>
parents:
22303
diff
changeset
|
2836 |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2837 def Test_nested_closure_used() |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2838 var lines =<< trim END |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2839 vim9script |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2840 def Func() |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2841 var x = 'hello' |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2842 var Closure = () => x |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2843 g:Myclosure = () => Closure() |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2844 enddef |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2845 Func() |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2846 assert_equal('hello', g:Myclosure()) |
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2847 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2848 v9.CheckScriptSuccess(lines) |
22541
7d6ba4204f66
patch 8.2.1819: Vim9: Memory leak when using a closure
Bram Moolenaar <Bram@vim.org>
parents:
22537
diff
changeset
|
2849 enddef |
22527
c3e3c5707fe9
patch 8.2.1812: Vim9: nested closure throws an internal error
Bram Moolenaar <Bram@vim.org>
parents:
22498
diff
changeset
|
2850 |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2851 def Test_nested_closure_fails() |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
2852 var lines =<< trim END |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2853 vim9script |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2854 def FuncA() |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2855 FuncB(0) |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2856 enddef |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2857 def FuncB(n: number): list<string> |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2858 return map([0], (_, v) => n) |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2859 enddef |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2860 FuncA() |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2861 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2862 v9.CheckScriptFailure(lines, 'E1012:') |
22401
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2863 enddef |
df1d7a560b35
patch 8.2.1749: Vim9: crash when closure fails in nested function
Bram Moolenaar <Bram@vim.org>
parents:
22371
diff
changeset
|
2864 |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2865 def Test_global_closure() |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2866 var lines =<< trim END |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2867 vim9script |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2868 def ReverseEveryNLines(n: number, line1: number, line2: number) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2869 var mods = 'sil keepj keepp lockm ' |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2870 var range = ':' .. line1 .. ',' .. line2 |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2871 def g:Offset(): number |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2872 var offset = (line('.') - line1 + 1) % n |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2873 return offset != 0 ? offset : n |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2874 enddef |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2875 exe mods .. range .. 'g/^/exe "m .-" .. g:Offset()' |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2876 enddef |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2877 |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2878 new |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2879 repeat(['aaa', 'bbb', 'ccc'], 3)->setline(1) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2880 ReverseEveryNLines(3, 1, 9) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2881 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2882 v9.CheckScriptSuccess(lines) |
23249
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2883 var expected = repeat(['ccc', 'bbb', 'aaa'], 3) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2884 assert_equal(expected, getline(1, 9)) |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2885 bwipe! |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2886 enddef |
43532077b5ff
patch 8.2.2170: Vim9: a global function defined in a :def function fails
Bram Moolenaar <Bram@vim.org>
parents:
23177
diff
changeset
|
2887 |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2888 def Test_global_closure_called_directly() |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2889 var lines =<< trim END |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2890 vim9script |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2891 def Outer() |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2892 var x = 1 |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2893 def g:Inner() |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2894 var y = x |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2895 x += 1 |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2896 assert_equal(1, y) |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2897 enddef |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2898 g:Inner() |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2899 assert_equal(2, x) |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2900 enddef |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2901 Outer() |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2902 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2903 v9.CheckScriptSuccess(lines) |
23285
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2904 delfunc g:Inner |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2905 enddef |
112fa621b127
patch 8.2.2188: Vim9: crash when calling global function from :def function
Bram Moolenaar <Bram@vim.org>
parents:
23281
diff
changeset
|
2906 |
26378
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2907 def Test_closure_called_from_legacy() |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2908 var lines =<< trim END |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2909 vim9script |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2910 def Func() |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2911 var outer = 'foo' |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2912 var F = () => { |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2913 outer = 'bar' |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2914 } |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2915 execute printf('call %s()', string(F)) |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2916 enddef |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2917 Func() |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2918 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2919 v9.CheckScriptFailure(lines, 'E1248') |
26378
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2920 enddef |
a926ccd92ae1
patch 8.2.3720: Vim9: Internal error when invoking closure in legacy context
Bram Moolenaar <Bram@vim.org>
parents:
26323
diff
changeset
|
2921 |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2922 def Test_failure_in_called_function() |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2923 # this was using the frame index as the return value |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2924 var lines =<< trim END |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2925 vim9script |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2926 au TerminalWinOpen * eval [][0] |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2927 def PopupTerm(a: any) |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2928 # make sure typvals on stack are string |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2929 ['a', 'b', 'c', 'd', 'e', 'f', 'g']->join() |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2930 FireEvent() |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2931 enddef |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2932 def FireEvent() |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2933 do TerminalWinOpen |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2934 enddef |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2935 # use try/catch to make eval fail |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2936 try |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2937 call PopupTerm(0) |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2938 catch |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2939 endtry |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2940 au! TerminalWinOpen |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2941 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2942 v9.CheckScriptSuccess(lines) |
23009
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2943 enddef |
1fa84623fc68
patch 8.2.2051: Vim9: crash when aborting a user function call
Bram Moolenaar <Bram@vim.org>
parents:
22973
diff
changeset
|
2944 |
22460
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2945 def Test_nested_lambda() |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2946 var lines =<< trim END |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2947 vim9script |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2948 def Func() |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2949 var x = 4 |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2950 var Lambda1 = () => 7 |
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
2951 var Lambda2 = () => [Lambda1(), x] |
22460
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2952 var res = Lambda2() |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2953 assert_equal([7, 4], res) |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2954 enddef |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2955 Func() |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2956 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2957 v9.CheckScriptSuccess(lines) |
22460
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2958 enddef |
4097509ecc1e
patch 8.2.1778: Vim9: returning from a partial call clears outer context
Bram Moolenaar <Bram@vim.org>
parents:
22437
diff
changeset
|
2959 |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2960 def Test_double_nested_lambda() |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2961 var lines =<< trim END |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2962 vim9script |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2963 def F(head: string): func(string): func(string): string |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2964 return (sep: string): func(string): string => ((tail: string): string => { |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2965 return head .. sep .. tail |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2966 }) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2967 enddef |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2968 assert_equal('hello-there', F('hello')('-')('there')) |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2969 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2970 v9.CheckScriptSuccess(lines) |
24858
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2971 enddef |
193cc8bd8a2f
patch 8.2.2967: Vim9: crash when using two levels of partials
Bram Moolenaar <Bram@vim.org>
parents:
24854
diff
changeset
|
2972 |
24651
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2973 def Test_nested_inline_lambda() |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2974 var lines =<< trim END |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2975 vim9script |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2976 def F(text: string): func(string): func(string): string |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2977 return (arg: string): func(string): string => ((sep: string): string => { |
25489
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25465
diff
changeset
|
2978 return sep .. arg .. text |
24651
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2979 }) |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2980 enddef |
25489
911fdca7f736
patch 8.2.3281: Vim9: TODO items in tests can be taken care of
Bram Moolenaar <Bram@vim.org>
parents:
25465
diff
changeset
|
2981 assert_equal('--there++', F('++')('there')('--')) |
24651
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
2982 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2983 v9.CheckScriptSuccess(lines) |
25265
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2984 |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2985 lines =<< trim END |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2986 vim9script |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2987 echo range(4)->mapnew((_, v) => { |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2988 return range(v) ->mapnew((_, s) => { |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2989 return string(s) |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2990 }) |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2991 }) |
1d6ff96306fc
patch 8.2.3169: Vim9: cannot handle nested inline function
Bram Moolenaar <Bram@vim.org>
parents:
25202
diff
changeset
|
2992 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
2993 v9.CheckScriptSuccess(lines) |
25276
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
2994 |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
2995 lines =<< trim END |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
2996 vim9script |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
2997 |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
2998 def Func() |
25276
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
2999 range(10) |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3000 ->mapnew((_, _) => ({ |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3001 key: range(10)->mapnew((_, _) => { |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3002 return ' ' |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3003 }), |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3004 })) |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3005 enddef |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3006 |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3007 defcomp |
d26dc79c533f
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Bram Moolenaar <Bram@vim.org>
parents:
25265
diff
changeset
|
3008 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3009 v9.CheckScriptSuccess(lines) |
24651
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3010 enddef |
5dea95170907
patch 8.2.2864: Vim9: crash when using inline function
Bram Moolenaar <Bram@vim.org>
parents:
24555
diff
changeset
|
3011 |
22910
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3012 def Shadowed(): list<number> |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
3013 var FuncList: list<func: number> = [() => 42] |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23559
diff
changeset
|
3014 return FuncList->mapnew((_, Shadowed) => Shadowed()) |
22910
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3015 enddef |
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3016 |
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3017 def Test_lambda_arg_shadows_func() |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3018 assert_equal([42], g:Shadowed()) |
22910
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3019 enddef |
f78057703df9
patch 8.2.2002: Vim9: lambda argument shadowed by function name
Bram Moolenaar <Bram@vim.org>
parents:
22908
diff
changeset
|
3020 |
28111
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3021 def Test_compiling_referenced_func_no_shadow() |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3022 var lines =<< trim END |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3023 vim9script |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3024 |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3025 def InitializeReply(lspserver: dict<any>) |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3026 enddef |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3027 |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3028 def ProcessReply(lspserver: dict<any>) |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3029 var lsp_reply_handlers: dict<func> = |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3030 { 'initialize': InitializeReply } |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3031 lsp_reply_handlers['initialize'](lspserver) |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3032 enddef |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3033 |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3034 call ProcessReply({}) |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3035 END |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3036 v9.CheckScriptSuccess(lines) |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3037 enddef |
d54541ce3e1b
patch 8.2.4580: Vim9: incorrect error for shadowing variable
Bram Moolenaar <Bram@vim.org>
parents:
28095
diff
changeset
|
3038 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3039 def s:Line_continuation_in_def(dir: string = ''): string |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3040 var path: string = empty(dir) |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3041 \ ? 'empty' |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3042 \ : 'full' |
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3043 return path |
20972
d561e3c6cd65
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3044 enddef |
d561e3c6cd65
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3045 |
d561e3c6cd65
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3046 def Test_line_continuation_in_def() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
3047 Line_continuation_in_def('.')->assert_equal('full') |
20972
d561e3c6cd65
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3048 enddef |
d561e3c6cd65
patch 8.2.1037: Vim9: crash when using line continuation inside :def
Bram Moolenaar <Bram@vim.org>
parents:
20945
diff
changeset
|
3049 |
22942
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3050 def Test_script_var_in_lambda() |
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3051 var lines =<< trim END |
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3052 vim9script |
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3053 var script = 'test' |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
3054 assert_equal(['test'], map(['one'], (_, _) => script)) |
22942
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3055 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3056 v9.CheckScriptSuccess(lines) |
22942
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3057 enddef |
4759d13193fb
patch 8.2.2018: Vim9: script variable not found from lambda
Bram Moolenaar <Bram@vim.org>
parents:
22936
diff
changeset
|
3058 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3059 def s:Line_continuation_in_lambda(): list<string> |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3060 var x = range(97, 100) |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23559
diff
changeset
|
3061 ->mapnew((_, v) => nr2char(v) |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
3062 ->toupper()) |
21208
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3063 ->reverse() |
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3064 return x |
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3065 enddef |
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3066 |
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3067 def Test_line_continuation_in_lambda() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
3068 Line_continuation_in_lambda()->assert_equal(['D', 'C', 'B', 'A']) |
23644
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3069 |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3070 var lines =<< trim END |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3071 vim9script |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3072 var res = [{n: 1, m: 2, s: 'xxx'}] |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3073 ->mapnew((_, v: dict<any>): string => printf('%d:%d:%s', |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3074 v.n, |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3075 v.m, |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3076 substitute(v.s, '.*', 'yyy', '') |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3077 )) |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3078 assert_equal(['1:2:yyy'], res) |
03acf9c49f07
patch 8.2.2364: Vim9: line break in lambda accesses freed memory
Bram Moolenaar <Bram@vim.org>
parents:
23630
diff
changeset
|
3079 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3080 v9.CheckScriptSuccess(lines) |
21208
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3081 enddef |
09377fd59b2e
patch 8.2.1155: Vim9: cannot handle line break inside lambda
Bram Moolenaar <Bram@vim.org>
parents:
21186
diff
changeset
|
3082 |
23547
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3083 def Test_list_lambda() |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3084 timer_start(1000, (_) => 0) |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3085 var body = execute(timer_info()[0].callback |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3086 ->string() |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3087 ->substitute("('", ' ', '') |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3088 ->substitute("')", '', '') |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3089 ->substitute('function\zs', ' ', '')) |
24398
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
3090 assert_match('def <lambda>\d\+(_: any): number\n1 return 0\n enddef', body) |
23547
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3091 enddef |
7f09cfa9ac4a
patch 8.2.2316: Vim9: cannot list a lambda function
Bram Moolenaar <Bram@vim.org>
parents:
23545
diff
changeset
|
3092 |
25370
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3093 def Test_lambda_block_variable() |
25344
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3094 var lines =<< trim END |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3095 vim9script |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3096 var flist: list<func> |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3097 for i in range(10) |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3098 var inloop = i |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3099 flist[i] = () => inloop |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3100 endfor |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3101 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3102 v9.CheckScriptSuccess(lines) |
25344
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3103 |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3104 lines =<< trim END |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3105 vim9script |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3106 if true |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3107 var outloop = 5 |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3108 var flist: list<func> |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3109 for i in range(10) |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3110 flist[i] = () => outloop |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3111 endfor |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3112 endif |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3113 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3114 v9.CheckScriptSuccess(lines) |
25344
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3115 |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3116 lines =<< trim END |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3117 vim9script |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3118 if true |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3119 var outloop = 5 |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3120 endif |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3121 var flist: list<func> |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3122 for i in range(10) |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3123 flist[i] = () => outloop |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3124 endfor |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3125 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3126 v9.CheckScriptFailure(lines, 'E1001: Variable not found: outloop', 1) |
25370
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3127 |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3128 lines =<< trim END |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3129 vim9script |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3130 for i in range(10) |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3131 var Ref = () => 0 |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3132 endfor |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3133 assert_equal(0, ((i) => 0)(0)) |
d52504ef26ed
patch 8.2.3222: Vim9: cannot used loop variable later as lambda argument
Bram Moolenaar <Bram@vim.org>
parents:
25344
diff
changeset
|
3134 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3135 v9.CheckScriptSuccess(lines) |
25344
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3136 enddef |
d1fcd9c14a93
patch 8.2.3209: Vim9: lambda doesn't find block-local variable
Bram Moolenaar <Bram@vim.org>
parents:
25316
diff
changeset
|
3137 |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3138 def Test_legacy_lambda() |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3139 legacy echo {x -> 'hello ' .. x}('foo') |
24539
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3140 |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3141 var lines =<< trim END |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3142 echo {x -> 'hello ' .. x}('foo') |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3143 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3144 v9.CheckDefAndScriptFailure(lines, 'E720:') |
24539
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3145 |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3146 lines =<< trim END |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3147 vim9script |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3148 def Func() |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3149 echo (() => 'no error')() |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3150 enddef |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3151 legacy call s:Func() |
3a290891a015
patch 8.2.2809: Vim9: :def function compilation fails when using :legacy
Bram Moolenaar <Bram@vim.org>
parents:
24531
diff
changeset
|
3152 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3153 v9.CheckScriptSuccess(lines) |
24531
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3154 enddef |
3bfec39ce31c
patch 8.2.2805: Vim9: cannot use legacy syntax in Vim9 script
Bram Moolenaar <Bram@vim.org>
parents:
24525
diff
changeset
|
3155 |
25030
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3156 def Test_legacy() |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3157 var lines =<< trim END |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3158 vim9script |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3159 func g:LegacyFunction() |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3160 let g:legacyvar = 1 |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3161 endfunc |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3162 def Testit() |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3163 legacy call g:LegacyFunction() |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3164 enddef |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3165 Testit() |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3166 assert_equal(1, g:legacyvar) |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3167 unlet g:legacyvar |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3168 delfunc g:LegacyFunction |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3169 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3170 v9.CheckScriptSuccess(lines) |
25030
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3171 enddef |
214fddf4c765
patch 8.2.3052: Vim9: "legacy call" does not work
Bram Moolenaar <Bram@vim.org>
parents:
24996
diff
changeset
|
3172 |
24776
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3173 def Test_legacy_errors() |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3174 for cmd in ['if', 'elseif', 'else', 'endif', |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3175 'for', 'endfor', 'continue', 'break', |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3176 'while', 'endwhile', |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3177 'try', 'catch', 'finally', 'endtry'] |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3178 v9.CheckDefFailure(['legacy ' .. cmd .. ' expr'], 'E1189:') |
24776
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3179 endfor |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3180 enddef |
7464d4c927f5
patch 8.2.2926: Vim9: no good error for using :legacy in a :def function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
3181 |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3182 def Test_call_legacy_with_dict() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3183 var lines =<< trim END |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3184 vim9script |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3185 func Legacy() dict |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3186 let g:result = self.value |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3187 endfunc |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3188 def TestDirect() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3189 var d = {value: 'yes', func: Legacy} |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3190 d.func() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3191 enddef |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3192 TestDirect() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3193 assert_equal('yes', g:result) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3194 unlet g:result |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3195 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3196 def TestIndirect() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3197 var d = {value: 'foo', func: Legacy} |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3198 var Fi = d.func |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3199 Fi() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3200 enddef |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3201 TestIndirect() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3202 assert_equal('foo', g:result) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3203 unlet g:result |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3204 |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3205 var d = {value: 'bar', func: Legacy} |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3206 d.func() |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3207 assert_equal('bar', g:result) |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3208 unlet g:result |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3209 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3210 v9.CheckScriptSuccess(lines) |
25800
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3211 enddef |
fe8d153cb268
patch 8.2.3435: Vim9: dict is not passed to dict function
Bram Moolenaar <Bram@vim.org>
parents:
25774
diff
changeset
|
3212 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3213 def s:DoFilterThis(a: string): list<string> |
23557
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3214 # closure nested inside another closure using argument |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3215 var Filter = (l) => filter(l, (_, v) => stridx(v, a) == 0) |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3216 return ['x', 'y', 'a', 'x2', 'c']->Filter() |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3217 enddef |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3218 |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3219 def Test_nested_closure_using_argument() |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3220 assert_equal(['x', 'x2'], DoFilterThis('x')) |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3221 enddef |
f50ee1ae4d9b
patch 8.2.2321: Vim9: cannot nest closures
Bram Moolenaar <Bram@vim.org>
parents:
23547
diff
changeset
|
3222 |
23559
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3223 def Test_triple_nested_closure() |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3224 var what = 'x' |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3225 var Match = (val: string, cmp: string): bool => stridx(val, cmp) == 0 |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3226 var Filter = (l) => filter(l, (_, v) => Match(v, what)) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3227 assert_equal(['x', 'x2'], ['x', 'y', 'a', 'x2', 'c']->Filter()) |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3228 enddef |
64dfb69e7d46
patch 8.2.2322: Vim9: closure nested limiting to one level
Bram Moolenaar <Bram@vim.org>
parents:
23557
diff
changeset
|
3229 |
21176
54c665ad2db3
patch 8.2.1139: Vim9: test for silent echo fails in some environments
Bram Moolenaar <Bram@vim.org>
parents:
21174
diff
changeset
|
3230 func Test_silent_echo() |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3231 CheckScreendump |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3232 call Run_Test_silent_echo() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3233 endfunc |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3234 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3235 def Run_Test_silent_echo() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3236 var lines =<< trim END |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3237 vim9script |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3238 def EchoNothing() |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3239 silent echo '' |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3240 enddef |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3241 defcompile |
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3242 END |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3243 writefile(lines, 'XTest_silent_echo') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3244 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3245 # Check that the balloon shows up after a mouse move |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3246 var buf = g:RunVimInTerminal('-S XTest_silent_echo', {'rows': 6}) |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3247 term_sendkeys(buf, ":abc") |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3248 g:VerifyScreenDump(buf, 'Test_vim9_silent_echo', {}) |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3249 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3250 # clean up |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3251 g:StopVimInTerminal(buf) |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3252 delete('XTest_silent_echo') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3253 enddef |
21172
96ae8622cfb6
patch 8.2.1137: Vim9: modifiers not cleared after compiling function
Bram Moolenaar <Bram@vim.org>
parents:
21170
diff
changeset
|
3254 |
22736
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3255 def SilentlyError() |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3256 execute('silent! invalid') |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3257 g:did_it = 'yes' |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3258 enddef |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3259 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3260 func s:UserError() |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3261 silent! invalid |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3262 endfunc |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3263 |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3264 def SilentlyUserError() |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3265 UserError() |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3266 g:did_it = 'yes' |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3267 enddef |
22736
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3268 |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3269 " This can't be a :def function, because the assert would not be reached. |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3270 func Test_ignore_silent_error() |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3271 let g:did_it = 'no' |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3272 call SilentlyError() |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3273 call assert_equal('yes', g:did_it) |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3274 |
22742
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3275 let g:did_it = 'no' |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3276 call SilentlyUserError() |
f7f2d73ff85e
patch 8.2.1919: assert_fails() setting emsg_silent changes normal execution
Bram Moolenaar <Bram@vim.org>
parents:
22736
diff
changeset
|
3277 call assert_equal('yes', g:did_it) |
22736
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3278 |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3279 unlet g:did_it |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3280 endfunc |
56907027dba7
patch 8.2.1916: Vim9: function call is aborted even when "silent!" is used
Bram Moolenaar <Bram@vim.org>
parents:
22734
diff
changeset
|
3281 |
22760
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3282 def Test_ignore_silent_error_in_filter() |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3283 var lines =<< trim END |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3284 vim9script |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3285 def Filter(winid: number, key: string): bool |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3286 if key == 'o' |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3287 silent! eval [][0] |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3288 return true |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3289 endif |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3290 return popup_filter_menu(winid, key) |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3291 enddef |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3292 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
3293 popup_create('popup', {filter: Filter}) |
22760
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3294 feedkeys("o\r", 'xnt') |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3295 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3296 v9.CheckScriptSuccess(lines) |
22760
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3297 enddef |
d235c5fa0bbe
patch 8.2.1928: Vim9: "silent!" not effective when list index is wrong
Bram Moolenaar <Bram@vim.org>
parents:
22742
diff
changeset
|
3298 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3299 def s:Fibonacci(n: number): number |
22135
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3300 if n < 2 |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3301 return n |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3302 else |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3303 return Fibonacci(n - 1) + Fibonacci(n - 2) |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3304 endif |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3305 enddef |
f45127fbe9ba
patch 8.2.1617: Vim9: cannot pass "true" to win_splitmove()
Bram Moolenaar <Bram@vim.org>
parents:
22133
diff
changeset
|
3306 |
21281
13b1567ae0c6
patch 8.2.1191: Vim9: crash when function calls itself
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3307 def Test_recursive_call() |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
3308 Fibonacci(20)->assert_equal(6765) |
21281
13b1567ae0c6
patch 8.2.1191: Vim9: crash when function calls itself
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3309 enddef |
13b1567ae0c6
patch 8.2.1191: Vim9: crash when function calls itself
Bram Moolenaar <Bram@vim.org>
parents:
21265
diff
changeset
|
3310 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3311 def s:TreeWalk(dir: string): list<any> |
23565
34aa2907082a
patch 8.2.2325: Vim9: crash if map() changes the item type
Bram Moolenaar <Bram@vim.org>
parents:
23559
diff
changeset
|
3312 return readdir(dir)->mapnew((_, val) => |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3313 fnamemodify(dir .. '/' .. val, ':p')->isdirectory() |
22936
00b0275ffe7f
patch 8.2.2015: Vim9: literal dict #{} is not like any other language
Bram Moolenaar <Bram@vim.org>
parents:
22910
diff
changeset
|
3314 ? {[val]: TreeWalk(dir .. '/' .. val)} |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3315 : val |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
3316 ) |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3317 enddef |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3318 |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3319 def Test_closure_in_map() |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3320 mkdir('XclosureDir/tdir', 'p') |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3321 writefile(['111'], 'XclosureDir/file1') |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3322 writefile(['222'], 'XclosureDir/file2') |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3323 writefile(['333'], 'XclosureDir/tdir/file3') |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3324 |
23072
4b398a229b0b
patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax
Bram Moolenaar <Bram@vim.org>
parents:
23009
diff
changeset
|
3325 TreeWalk('XclosureDir')->assert_equal(['file1', 'file2', {tdir: ['file3']}]) |
21303
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3326 |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3327 delete('XclosureDir', 'rf') |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3328 enddef |
7c50dfe302f8
patch 8.2.1202: Vim9: crash when calling a closure from a builtin function
Bram Moolenaar <Bram@vim.org>
parents:
21301
diff
changeset
|
3329 |
22496
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3330 def Test_invalid_function_name() |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3331 var lines =<< trim END |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3332 vim9script |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3333 def s: list<string> |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3334 END |
27669
5c4ab8d4472c
patch 8.2.4360: Vim9: allowing use of "s:" leads to inconsistencies
Bram Moolenaar <Bram@vim.org>
parents:
27611
diff
changeset
|
3335 v9.CheckScriptFailure(lines, 'E1268:') |
22496
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3336 |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3337 lines =<< trim END |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3338 vim9script |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3339 def g: list<string> |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3340 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3341 v9.CheckScriptFailure(lines, 'E129:') |
22496
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3342 |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3343 lines =<< trim END |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3344 vim9script |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3345 def <SID>: list<string> |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3346 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3347 v9.CheckScriptFailure(lines, 'E884:') |
22496
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3348 |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3349 lines =<< trim END |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3350 vim9script |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3351 def F list<string> |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3352 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3353 v9.CheckScriptFailure(lines, 'E488:') |
22496
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3354 enddef |
454b78ca8247
patch 8.2.1796: Vim9: invalid memory access with weird function name
Bram Moolenaar <Bram@vim.org>
parents:
22468
diff
changeset
|
3355 |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21345
diff
changeset
|
3356 def Test_partial_call() |
25465
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3357 var lines =<< trim END |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3358 var Xsetlist: func |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3359 Xsetlist = function('setloclist', [0]) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3360 Xsetlist([], ' ', {title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3361 getloclist(0, {title: 1})->assert_equal({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3362 |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3363 Xsetlist = function('setloclist', [0, [], ' ']) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3364 Xsetlist({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3365 getloclist(0, {title: 1})->assert_equal({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3366 |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3367 Xsetlist = function('setqflist') |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3368 Xsetlist([], ' ', {title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3369 getqflist({title: 1})->assert_equal({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3370 |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3371 Xsetlist = function('setqflist', [[], ' ']) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3372 Xsetlist({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3373 getqflist({title: 1})->assert_equal({title: 'test'}) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3374 |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3375 var Len: func: number = function('len', ['word']) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3376 assert_equal(4, Len()) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3377 |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3378 var RepeatFunc = function('repeat', ['o']) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3379 assert_equal('ooooo', RepeatFunc(5)) |
b8a6a0007dc3
patch 8.2.3269: Vim9: wrong argument check for partial
Bram Moolenaar <Bram@vim.org>
parents:
25370
diff
changeset
|
3380 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3381 v9.CheckDefAndScriptSuccess(lines) |
25646
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3382 |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3383 lines =<< trim END |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3384 vim9script |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3385 def Foo(Parser: any) |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3386 enddef |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3387 var Expr: func(dict<any>): dict<any> |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3388 const Call = Foo(Expr) |
99fbffe75217
patch 8.2.3359: Vim9: error for type when variable is not set
Bram Moolenaar <Bram@vim.org>
parents:
25632
diff
changeset
|
3389 END |
28002
1012048eed26
patch 8.2.4526: Vim9: cannot set variables to a null value
Bram Moolenaar <Bram@vim.org>
parents:
27918
diff
changeset
|
3390 v9.CheckScriptFailure(lines, 'E1031:') |
21347
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21345
diff
changeset
|
3391 enddef |
d636c7bbe9ab
patch 8.2.1224: Vim9: arguments from partial are not used
Bram Moolenaar <Bram@vim.org>
parents:
21345
diff
changeset
|
3392 |
27756
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3393 def Test_partial_double_nested() |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3394 var idx = 123 |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3395 var Get = () => idx |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3396 var Ref = function(Get, []) |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3397 var RefRef = function(Ref, []) |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3398 assert_equal(123, RefRef()) |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3399 enddef |
60ac4228a73d
patch 8.2.4404: Vim9: some code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27740
diff
changeset
|
3400 |
28006
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3401 def Test_partial_null_function() |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3402 var lines =<< trim END |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3403 var d: dict<func> = {f: null_function} |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3404 var Ref = d.f |
28008
cc7d54a134e4
patch 8.2.4529: Vim9: comparing partial with function fails
Bram Moolenaar <Bram@vim.org>
parents:
28006
diff
changeset
|
3405 assert_equal('func(...): unknown', typename(Ref)) |
28006
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3406 END |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3407 v9.CheckDefAndScriptSuccess(lines) |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3408 enddef |
02f787034998
patch 8.2.4528: crash when using null_function for a partial
Bram Moolenaar <Bram@vim.org>
parents:
28002
diff
changeset
|
3409 |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3410 " Using "idx" from a legacy global function does not work. |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3411 " This caused a crash when called from legacy context. |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3412 func Test_partial_call_fails() |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3413 let lines =<< trim END |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3414 vim9script |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3415 |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3416 var l = ['a', 'b', 'c'] |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3417 def Iter(container: any): any |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3418 var idx = -1 |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3419 var obj = {state: container} |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
3420 def g:NextItem__(self: dict<any>): any |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3421 ++idx |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3422 return self.state[idx] |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3423 enddef |
27593
8c7836f8668d
patch 8.2.4323: Vim9: nested function name can start with "_"
Bram Moolenaar <Bram@vim.org>
parents:
27591
diff
changeset
|
3424 obj.__next__ = function('g:NextItem__', [obj]) |
27565
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3425 return obj |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3426 enddef |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3427 |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3428 var it = Iter(l) |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3429 echo it.__next__() |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3430 END |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3431 call writefile(lines, 'XpartialCall') |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3432 try |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3433 source XpartialCall |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3434 catch /E1248:/ |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3435 endtry |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3436 call delete('XpartialCall') |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3437 endfunc |
0b12dd90a5d6
patch 8.2.4309: Vim9: crash when using a partial in the wrong context
Bram Moolenaar <Bram@vim.org>
parents:
27519
diff
changeset
|
3438 |
21689
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3439 def Test_cmd_modifier() |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3440 tab echo '0' |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3441 v9.CheckDefFailure(['5tab echo 3'], 'E16:') |
21689
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3442 enddef |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3443 |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3444 def Test_restore_modifiers() |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3445 # check that when compiling a :def function command modifiers are not messed |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3446 # up. |
22435
166a0f17b05e
patch 8.2.1766: Vim9: Some tests are still using :let
Bram Moolenaar <Bram@vim.org>
parents:
22401
diff
changeset
|
3447 var lines =<< trim END |
21689
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3448 vim9script |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3449 set eventignore= |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3450 autocmd QuickFixCmdPost * copen |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3451 def AutocmdsDisabled() |
25202
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
3452 eval 1 + 2 |
21689
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3453 enddef |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3454 func Func() |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3455 noautocmd call s:AutocmdsDisabled() |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3456 let g:ei_after = &eventignore |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3457 endfunc |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3458 Func() |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3459 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3460 v9.CheckScriptSuccess(lines) |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
3461 g:ei_after->assert_equal('') |
21689
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3462 enddef |
10866fd07595
patch 8.2.1394: Vim9: compiling a function interferes with command modifiers
Bram Moolenaar <Bram@vim.org>
parents:
21685
diff
changeset
|
3463 |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3464 def StackTop() |
25202
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
3465 eval 1 + 2 |
e5d85e83a887
patch 8.2.3137: Vim9: no error when a line only has a variable name
Bram Moolenaar <Bram@vim.org>
parents:
25126
diff
changeset
|
3466 eval 2 + 3 |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3467 # call not on fourth line |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3468 g:StackBot() |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3469 enddef |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3470 |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3471 def StackBot() |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3472 # throw an error |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3473 eval [][0] |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3474 enddef |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3475 |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3476 def Test_callstack_def() |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3477 try |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3478 g:StackTop() |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3479 catch |
22222
7b9e8fd7ea5b
patch 8.2.1660: assert functions require passing expected as first argument
Bram Moolenaar <Bram@vim.org>
parents:
22216
diff
changeset
|
3480 v:throwpoint->assert_match('Test_callstack_def\[2\]..StackTop\[4\]..StackBot, line 2') |
22214
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3481 endtry |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3482 enddef |
efa1511a5bf3
patch 8.2.1656: Vim9: callstack wrong if :def function calls :def function
Bram Moolenaar <Bram@vim.org>
parents:
22165
diff
changeset
|
3483 |
22537
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3484 " Re-using spot for variable used in block |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3485 def Test_block_scoped_var() |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3486 var lines =<< trim END |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3487 vim9script |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3488 def Func() |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3489 var x = ['a', 'b', 'c'] |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3490 if 1 |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3491 var y = 'x' |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
3492 map(x, (_, _) => y) |
22537
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3493 endif |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3494 var z = x |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3495 assert_equal(['x', 'x', 'x'], z) |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3496 enddef |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3497 Func() |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3498 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3499 v9.CheckScriptSuccess(lines) |
22537
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3500 enddef |
9870e8b6ed78
patch 8.2.1817: Vim9: wrong instruction when reusing a local variable spot
Bram Moolenaar <Bram@vim.org>
parents:
22535
diff
changeset
|
3501 |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3502 def Test_reset_did_emsg() |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3503 var lines =<< trim END |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3504 @s = 'blah' |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3505 au BufWinLeave * # |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3506 def Func() |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3507 var winid = popup_create('popup', {}) |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3508 exe '*s' |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3509 popup_close(winid) |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3510 enddef |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3511 Func() |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3512 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3513 v9.CheckScriptFailure(lines, 'E492:', 8) |
23092
c713358da074
patch 8.2.2092: Vim9: unpredictable errors for script tests
Bram Moolenaar <Bram@vim.org>
parents:
23074
diff
changeset
|
3514 delfunc! g:Func |
22948
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3515 enddef |
707b90980de5
patch 8.2.2021: Vim9: get E1099 when autocommand resets did_emsg
Bram Moolenaar <Bram@vim.org>
parents:
22942
diff
changeset
|
3516 |
23177
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3517 def Test_did_emsg_reset() |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3518 # executing an autocommand resets did_emsg, this should not result in a |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3519 # builtin function considered failing |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3520 var lines =<< trim END |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3521 vim9script |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3522 au BufWinLeave * # |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3523 def Func() |
24398
bed5ec739304
patch 8.2.2739: Vim9: a lambda accepts too many arguments at the script level
Bram Moolenaar <Bram@vim.org>
parents:
24371
diff
changeset
|
3524 popup_menu('', {callback: (a, b) => popup_create('', {})->popup_close()}) |
23177
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3525 eval [][0] |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3526 enddef |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3527 nno <F3> <cmd>call <sid>Func()<cr> |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3528 feedkeys("\<F3>\e", 'xt') |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3529 END |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3530 writefile(lines, 'XemsgReset') |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3531 assert_fails('so XemsgReset', ['E684:', 'E684:'], lines, 2) |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3532 delete('XemsgReset') |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3533 nunmap <F3> |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3534 au! BufWinLeave |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3535 enddef |
cc24ac009f29
patch 8.2.2134: Vim9: get E1099 when autocmd triggered in builtin function
Bram Moolenaar <Bram@vim.org>
parents:
23171
diff
changeset
|
3536 |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3537 def Test_abort_with_silent_call() |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3538 var lines =<< trim END |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3539 vim9script |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3540 g:result = 'none' |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3541 def Func() |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3542 g:result += 3 |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3543 g:result = 'yes' |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3544 enddef |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3545 # error is silenced, but function aborts on error |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3546 silent! Func() |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3547 assert_equal('none', g:result) |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3548 unlet g:result |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3549 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3550 v9.CheckScriptSuccess(lines) |
23102
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3551 enddef |
3239b0f3c592
patch 8.2.2097: Vim9: using :silent! when calling a function prevents abort
Bram Moolenaar <Bram@vim.org>
parents:
23100
diff
changeset
|
3552 |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3553 def Test_continues_with_silent_error() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3554 var lines =<< trim END |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3555 vim9script |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3556 g:result = 'none' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3557 def Func() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3558 silent! g:result += 3 |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3559 g:result = 'yes' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3560 enddef |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3561 # error is silenced, function does not abort |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3562 Func() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3563 assert_equal('yes', g:result) |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3564 unlet g:result |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3565 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3566 v9.CheckScriptSuccess(lines) |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3567 enddef |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3568 |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3569 def Test_abort_even_with_silent() |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3570 var lines =<< trim END |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3571 vim9script |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3572 g:result = 'none' |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3573 def Func() |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3574 eval {-> ''}() .. '' .. {}['X'] |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3575 g:result = 'yes' |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3576 enddef |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3577 silent! Func() |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3578 assert_equal('none', g:result) |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3579 unlet g:result |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3580 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3581 v9.CheckScriptSuccess(lines) |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3582 enddef |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3583 |
23100
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3584 def Test_cmdmod_silent_restored() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3585 var lines =<< trim END |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3586 vim9script |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3587 def Func() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3588 g:result = 'none' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3589 silent! g:result += 3 |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3590 g:result = 'none' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3591 g:result += 3 |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3592 enddef |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3593 Func() |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3594 END |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3595 # can't use CheckScriptFailure, it ignores the :silent! |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3596 var fname = 'Xdefsilent' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3597 writefile(lines, fname) |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3598 var caught = 'no' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3599 try |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3600 exe 'source ' .. fname |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3601 catch /E1030:/ |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3602 caught = 'yes' |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3603 assert_match('Func, line 4', v:throwpoint) |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3604 endtry |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3605 assert_equal('yes', caught) |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3606 delete(fname) |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3607 enddef |
9c3a6c33c0e5
patch 8.2.2096: Vim9: command modifiers not restored after assignment
Bram Moolenaar <Bram@vim.org>
parents:
23098
diff
changeset
|
3608 |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3609 def Test_cmdmod_silent_nested() |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3610 var lines =<< trim END |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3611 vim9script |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3612 var result = '' |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3613 |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3614 def Error() |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3615 result ..= 'Eb' |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3616 eval [][0] |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3617 result ..= 'Ea' |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3618 enddef |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3619 |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3620 def Crash() |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3621 result ..= 'Cb' |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3622 sil! Error() |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3623 result ..= 'Ca' |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3624 enddef |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3625 |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3626 Crash() |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3627 assert_equal('CbEbEaCa', result) |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3628 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3629 v9.CheckScriptSuccess(lines) |
24218
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3630 enddef |
40e27d96e395
patch 8.2.2650: Vim9: command modifiers not handled in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24208
diff
changeset
|
3631 |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3632 def Test_dict_member_with_silent() |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3633 var lines =<< trim END |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3634 vim9script |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3635 g:result = 'none' |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3636 var d: dict<any> |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3637 def Func() |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3638 try |
23428
5807e3958e38
patch 8.2.2257: Vim9: using -> for lambda is ambiguous
Bram Moolenaar <Bram@vim.org>
parents:
23426
diff
changeset
|
3639 g:result = map([], (_, v) => ({}[v]))->join() .. d[''] |
23098
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3640 catch |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3641 endtry |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3642 enddef |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3643 silent! Func() |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3644 assert_equal('0', g:result) |
bdafc132a4a1
patch 8.2.2095: Vim9: crash when failed dict member is followed by concat
Bram Moolenaar <Bram@vim.org>
parents:
23092
diff
changeset
|
3645 unlet g:result |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3646 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3647 v9.CheckScriptSuccess(lines) |
23074
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3648 enddef |
cd885eb0e50c
patch 8.2.2083: Vim9: crash when using ":silent!" and getting member fails
Bram Moolenaar <Bram@vim.org>
parents:
23072
diff
changeset
|
3649 |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3650 def Test_skip_cmds_with_silent() |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3651 var lines =<< trim END |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3652 vim9script |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3653 |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3654 def Func(b: bool) |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3655 Crash() |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3656 enddef |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3657 |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3658 def Crash() |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3659 sil! :/not found/d _ |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3660 sil! :/not found/put _ |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3661 enddef |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3662 |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3663 Func(true) |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3664 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3665 v9.CheckScriptSuccess(lines) |
23689
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3666 enddef |
e7f5931b46ca
patch 8.2.2386: Vim9: crash when using ":silent! put"
Bram Moolenaar <Bram@vim.org>
parents:
23644
diff
changeset
|
3667 |
23281
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3668 def Test_opfunc() |
27464
a14c4d3e3260
patch 8.2.4260: Vim9: can still use a global function without g:
Bram Moolenaar <Bram@vim.org>
parents:
27457
diff
changeset
|
3669 nnoremap <F3> <cmd>set opfunc=g:Opfunc<cr>g@ |
23281
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3670 def g:Opfunc(_: any): string |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3671 setline(1, 'ASDF') |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3672 return '' |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3673 enddef |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3674 new |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3675 setline(1, 'asdf') |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3676 feedkeys("\<F3>$", 'x') |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3677 assert_equal('ASDF', getline(1)) |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3678 |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3679 bwipe! |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3680 nunmap <F3> |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3681 enddef |
5b4db8035d1d
patch 8.2.2186: Vim9: error when using 'opfunc'
Bram Moolenaar <Bram@vim.org>
parents:
23252
diff
changeset
|
3682 |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3683 func Test_opfunc_error() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3684 CheckScreendump |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3685 call Run_Test_opfunc_error() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3686 endfunc |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3687 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3688 def Run_Test_opfunc_error() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3689 # test that the error from Opfunc() is displayed right away |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3690 var lines =<< trim END |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3691 vim9script |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3692 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3693 def Opfunc(type: string) |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3694 try |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3695 eval [][0] |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3696 catch /nothing/ # error not caught |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3697 endtry |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3698 enddef |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3699 &operatorfunc = Opfunc |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3700 nnoremap <expr> l <SID>L() |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3701 def L(): string |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3702 return 'l' |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3703 enddef |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3704 'x'->repeat(10)->setline(1) |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3705 feedkeys('g@l', 'n') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3706 feedkeys('llll') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3707 END |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3708 call writefile(lines, 'XTest_opfunc_error') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3709 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3710 var buf = g:RunVimInTerminal('-S XTest_opfunc_error', {rows: 6, wait_for_ruler: 0}) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3711 g:WaitForAssert(() => assert_match('Press ENTER', term_getline(buf, 6))) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3712 g:WaitForAssert(() => assert_match('E684: list index out of range: 0', term_getline(buf, 5))) |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3713 |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3714 # clean up |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3715 g:StopVimInTerminal(buf) |
26538
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3716 delete('XTest_opfunc_error') |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3717 enddef |
dfa658800f21
patch 8.2.3798: a :def callback function postpones an error message
Bram Moolenaar <Bram@vim.org>
parents:
26530
diff
changeset
|
3718 |
23289
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3719 " this was crashing on exit |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3720 def Test_nested_lambda_in_closure() |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3721 var lines =<< trim END |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3722 vim9script |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24539
diff
changeset
|
3723 command WriteDone writefile(['Done'], 'XnestedDone') |
23289
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3724 def Outer() |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3725 def g:Inner() |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3726 echo map([1, 2, 3], {_, v -> v + 1}) |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3727 enddef |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3728 g:Inner() |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3729 enddef |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3730 defcompile |
24555
83877a1b66fd
patch 8.2.2817: Vim9: script sourcing continues after an error
Bram Moolenaar <Bram@vim.org>
parents:
24539
diff
changeset
|
3731 # not reached |
23289
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3732 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3733 if !g:RunVim([], lines, '--clean -c WriteDone -c quit') |
23289
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3734 return |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3735 endif |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3736 assert_equal(['Done'], readfile('XnestedDone')) |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3737 delete('XnestedDone') |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3738 enddef |
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
3739 |
27589
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3740 def Test_nested_closure_funcref() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3741 var lines =<< trim END |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3742 vim9script |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3743 def Func() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3744 var n: number |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3745 def Nested() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3746 ++n |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3747 enddef |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3748 Nested() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3749 g:result_one = n |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3750 var Ref = function(Nested) |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3751 Ref() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3752 g:result_two = n |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3753 enddef |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3754 Func() |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3755 END |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3756 v9.CheckScriptSuccess(lines) |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3757 assert_equal(1, g:result_one) |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3758 assert_equal(2, g:result_two) |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3759 unlet g:result_one g:result_two |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3760 enddef |
ecea41486e8a
patch 8.2.4321: Vim9: crash when using a funcref to a closure
Bram Moolenaar <Bram@vim.org>
parents:
27565
diff
changeset
|
3761 |
27591
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3762 def Test_nested_closure_in_dict() |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3763 var lines =<< trim END |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3764 vim9script |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3765 def Func(): dict<any> |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3766 var n: number |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3767 def Inc(): number |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3768 ++n |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3769 return n |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3770 enddef |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3771 return {inc: function(Inc)} |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3772 enddef |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3773 disas Func |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3774 var d = Func() |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3775 assert_equal(1, d.inc()) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3776 assert_equal(2, d.inc()) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3777 END |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3778 v9.CheckScriptSuccess(lines) |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3779 enddef |
d91be28bbdbb
patch 8.2.4322: Vim9: crash when using funcref with closure
Bram Moolenaar <Bram@vim.org>
parents:
27589
diff
changeset
|
3780 |
28047
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3781 def Test_script_local_other_script() |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3782 var lines =<< trim END |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3783 function LegacyJob() |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3784 let FuncRef = function('s:close_cb') |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3785 endfunction |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3786 function s:close_cb(...) |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3787 endfunction |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3788 END |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3789 lines->writefile('Xlegacy.vim') |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3790 source Xlegacy.vim |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3791 g:LegacyJob() |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3792 g:LegacyJob() |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3793 g:LegacyJob() |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3794 |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3795 delfunc g:LegacyJob |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3796 delete('Xlegacy.vim') |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3797 enddef |
b10fa9b17c85
patch 8.2.4548: script-local function is deleted when used in a funcref
Bram Moolenaar <Bram@vim.org>
parents:
28008
diff
changeset
|
3798 |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3799 def Test_check_func_arg_types() |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3800 var lines =<< trim END |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3801 vim9script |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3802 def F1(x: string): string |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3803 return x |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3804 enddef |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3805 |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3806 def F2(x: number): number |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3807 return x + 1 |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3808 enddef |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3809 |
28123
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
3810 def G(Fg: func): dict<func> |
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
3811 return {f: Fg} |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3812 enddef |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3813 |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3814 def H(d: dict<func>): string |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3815 return d.f('a') |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3816 enddef |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3817 END |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3818 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3819 v9.CheckScriptSuccess(lines + ['echo H(G(F1))']) |
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3820 v9.CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') |
28123
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
3821 |
e5fcd1256ee3
patch 8.2.4586: Vim9: no error for using lower case name for "func" argument
Bram Moolenaar <Bram@vim.org>
parents:
28111
diff
changeset
|
3822 v9.CheckScriptFailure(lines + ['def SomeFunc(ff: func)', 'enddef'], 'E704:') |
24065
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3823 enddef |
a6aec9a89184
patch 8.2.2574: Vim9: crash when calling partial with wrong function
Bram Moolenaar <Bram@vim.org>
parents:
24061
diff
changeset
|
3824 |
28059
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3825 def Test_call_func_with_null() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3826 var lines =<< trim END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3827 def Fstring(v: string) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3828 assert_equal(null_string, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3829 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3830 Fstring(null_string) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3831 def Fblob(v: blob) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3832 assert_equal(null_blob, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3833 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3834 Fblob(null_blob) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3835 def Flist(v: list<number>) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3836 assert_equal(null_list, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3837 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3838 Flist(null_list) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3839 def Fdict(v: dict<number>) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3840 assert_equal(null_dict, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3841 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3842 Fdict(null_dict) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3843 def Ffunc(Fv: func(number): number) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3844 assert_equal(null_function, Fv) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3845 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3846 Ffunc(null_function) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3847 if has('channel') |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3848 def Fchannel(v: channel) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3849 assert_equal(null_channel, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3850 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3851 Fchannel(null_channel) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3852 def Fjob(v: job) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3853 assert_equal(null_job, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3854 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3855 Fjob(null_job) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3856 endif |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3857 END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3858 v9.CheckDefAndScriptSuccess(lines) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3859 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3860 |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3861 def Test_null_default_argument() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3862 var lines =<< trim END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3863 def Fstring(v: string = null_string) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3864 assert_equal(null_string, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3865 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3866 Fstring() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3867 def Fblob(v: blob = null_blob) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3868 assert_equal(null_blob, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3869 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3870 Fblob() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3871 def Flist(v: list<number> = null_list) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3872 assert_equal(null_list, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3873 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3874 Flist() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3875 def Fdict(v: dict<number> = null_dict) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3876 assert_equal(null_dict, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3877 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3878 Fdict() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3879 def Ffunc(Fv: func(number): number = null_function) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3880 assert_equal(null_function, Fv) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3881 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3882 Ffunc() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3883 if has('channel') |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3884 def Fchannel(v: channel = null_channel) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3885 assert_equal(null_channel, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3886 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3887 Fchannel() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3888 def Fjob(v: job = null_job) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3889 assert_equal(null_job, v) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3890 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3891 Fjob() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3892 endif |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3893 END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3894 v9.CheckDefAndScriptSuccess(lines) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3895 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3896 |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3897 def Test_null_return() |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3898 var lines =<< trim END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3899 def Fstring(): string |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3900 return null_string |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3901 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3902 assert_equal(null_string, Fstring()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3903 def Fblob(): blob |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3904 return null_blob |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3905 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3906 assert_equal(null_blob, Fblob()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3907 def Flist(): list<number> |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3908 return null_list |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3909 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3910 assert_equal(null_list, Flist()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3911 def Fdict(): dict<number> |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3912 return null_dict |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3913 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3914 assert_equal(null_dict, Fdict()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3915 def Ffunc(): func(number): number |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3916 return null_function |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3917 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3918 assert_equal(null_function, Ffunc()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3919 if has('channel') |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3920 def Fchannel(): channel |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3921 return null_channel |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3922 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3923 assert_equal(null_channel, Fchannel()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3924 def Fjob(): job |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3925 return null_job |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3926 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3927 assert_equal(null_job, Fjob()) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3928 endif |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3929 END |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3930 v9.CheckDefAndScriptSuccess(lines) |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3931 enddef |
230115610b6a
patch 8.2.4554: Vim9: using null values not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents:
28047
diff
changeset
|
3932 |
25579
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3933 def Test_list_any_type_checked() |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3934 var lines =<< trim END |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3935 vim9script |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3936 def Foo() |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3937 --decl-- |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3938 Bar(l) |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3939 enddef |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3940 def Bar(ll: list<dict<any>>) |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3941 enddef |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3942 Foo() |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3943 END |
27519
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27472
diff
changeset
|
3944 # "any" could be "dict<any>", thus OK |
25579
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3945 lines[2] = 'var l: list<any>' |
27519
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27472
diff
changeset
|
3946 v9.CheckScriptSuccess(lines) |
25579
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3947 lines[2] = 'var l: list<any> = []' |
27519
7898c7847293
patch 8.2.4287: cannot assign empty list with type to variable with list type
Bram Moolenaar <Bram@vim.org>
parents:
27472
diff
changeset
|
3948 v9.CheckScriptSuccess(lines) |
25579
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3949 |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3950 lines[2] = 'var l: list<any> = [11]' |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3951 v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected list<dict<any>> but got list<number>', 2) |
25579
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3952 enddef |
d8fb5bb88362
patch 8.2.3326: Vim9: no error passing an empty list of the wrong type
Bram Moolenaar <Bram@vim.org>
parents:
25561
diff
changeset
|
3953 |
24404
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3954 def Test_compile_error() |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3955 var lines =<< trim END |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3956 def g:Broken() |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3957 echo 'a' + {} |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3958 enddef |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3959 call g:Broken() |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3960 END |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3961 # First call: compilation error |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3962 v9.CheckScriptFailure(lines, 'E1051: Wrong argument type for +') |
24404
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3963 |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3964 # Second call won't try compiling again |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3965 assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken') |
24406
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3966 delfunc g:Broken |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3967 |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3968 # No error when compiling with :silent! |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3969 lines =<< trim END |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3970 def g:Broken() |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3971 echo 'a' + [] |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3972 enddef |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3973 silent! defcompile |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3974 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
3975 v9.CheckScriptSuccess(lines) |
24406
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3976 |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3977 # Calling the function won't try compiling again |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3978 assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken') |
a26f0fa12845
patch 8.2.2743: Vim9: function state stuck when compiling with ":silent!"
Bram Moolenaar <Bram@vim.org>
parents:
24404
diff
changeset
|
3979 delfunc g:Broken |
24404
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3980 enddef |
a2a7d2d6e724
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Bram Moolenaar <Bram@vim.org>
parents:
24402
diff
changeset
|
3981 |
24408
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3982 def Test_ignored_argument() |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3983 var lines =<< trim END |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3984 vim9script |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3985 def Ignore(_, _): string |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3986 return 'yes' |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3987 enddef |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3988 assert_equal('yes', Ignore(1, 2)) |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3989 |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3990 func Ok(_) |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3991 return a:_ |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3992 endfunc |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3993 assert_equal('ok', Ok('ok')) |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3994 |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3995 func Oktoo() |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3996 let _ = 'too' |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3997 return _ |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3998 endfunc |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
3999 assert_equal('too', Oktoo()) |
24420
e0fa539a9b34
patch 8.2.2750: Vim9: error for using underscore in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
4000 |
e0fa539a9b34
patch 8.2.2750: Vim9: error for using underscore in nested function
Bram Moolenaar <Bram@vim.org>
parents:
24414
diff
changeset
|
4001 assert_equal([[1], [2], [3]], range(3)->mapnew((_, v) => [v]->map((_, w) => w + 1))) |
24408
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4002 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4003 v9.CheckScriptSuccess(lines) |
24408
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4004 |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4005 lines =<< trim END |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4006 def Ignore(_: string): string |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4007 return _ |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4008 enddef |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4009 defcompile |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4010 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4011 v9.CheckScriptFailure(lines, 'E1181:', 1) |
24408
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4012 |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4013 lines =<< trim END |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4014 var _ = 1 |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4015 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4016 v9.CheckDefAndScriptFailure(lines, 'E1181:', 1) |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
4017 |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
4018 lines =<< trim END |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
4019 var x = _ |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
4020 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4021 v9.CheckDefAndScriptFailure(lines, 'E1181:', 1) |
24408
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4022 enddef |
96e0b898d5b4
patch 8.2.2744: Vim9: no way to explicitly ignore an argument
Bram Moolenaar <Bram@vim.org>
parents:
24406
diff
changeset
|
4023 |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4024 def Test_too_many_arguments() |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4025 var lines =<< trim END |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4026 echo [0, 1, 2]->map(() => 123) |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4027 END |
27798
324d394e314e
patch 8.2.4425: map() function does not check function arguments
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
4028 v9.CheckDefAndScriptFailure(lines, ['E176:', 'E1106: 2 arguments too many'], 1) |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4029 |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4030 lines =<< trim END |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4031 echo [0, 1, 2]->map((_) => 123) |
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4032 END |
27798
324d394e314e
patch 8.2.4425: map() function does not check function arguments
Bram Moolenaar <Bram@vim.org>
parents:
27762
diff
changeset
|
4033 v9.CheckDefAndScriptFailure(lines, ['E176', 'E1106: One argument too many'], 1) |
24414
f539864ba851
patch 8.2.2747: Vim9: not always an error for too many function arguments
Bram Moolenaar <Bram@vim.org>
parents:
24408
diff
changeset
|
4034 enddef |
23289
ac701146c708
patch 8.2.2190: Vim9: crash when compiled with EXITFREE
Bram Moolenaar <Bram@vim.org>
parents:
23285
diff
changeset
|
4035 |
24525
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4036 def Test_closing_brace_at_start_of_line() |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4037 var lines =<< trim END |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4038 def Func() |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4039 enddef |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4040 Func( |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4041 ) |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4042 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4043 v9.CheckDefAndScriptSuccess(lines) |
24525
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4044 enddef |
887121a6d7cf
patch 8.2.2802: Vim9: illegal memory access
Bram Moolenaar <Bram@vim.org>
parents:
24436
diff
changeset
|
4045 |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4046 func s:CreateMydict() |
25630
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4047 let g:mydict = {} |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4048 func g:mydict.afunc() |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4049 let g:result = self.key |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4050 endfunc |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4051 endfunc |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4052 |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4053 def Test_numbered_function_reference() |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4054 CreateMydict() |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4055 var output = execute('legacy func g:mydict.afunc') |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4056 var funcName = 'g:' .. substitute(output, '.*function \(\d\+\).*', '\1', '') |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4057 execute 'function(' .. funcName .. ', [], {key: 42})()' |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4058 # check that the function still exists |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4059 assert_equal(output, execute('legacy func g:mydict.afunc')) |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4060 unlet g:mydict |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4061 enddef |
c26eb08a0df2
patch 8.2.3351: Vim9: using a function by name may delete it
Bram Moolenaar <Bram@vim.org>
parents:
25609
diff
changeset
|
4062 |
26960
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4063 def Test_go_beyond_end_of_cmd() |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4064 # this was reading the byte after the end of the line |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4065 var lines =<< trim END |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4066 def F() |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4067 cal |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4068 enddef |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4069 defcompile |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4070 END |
27457
4c16acb2525f
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Bram Moolenaar <Bram@vim.org>
parents:
27219
diff
changeset
|
4071 v9.CheckScriptFailure(lines, 'E476:') |
26960
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4072 enddef |
043a15b37bf1
patch 8.2.4009: reading one byte beyond the end of the line
Bram Moolenaar <Bram@vim.org>
parents:
26925
diff
changeset
|
4073 |
28382
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4074 " Test for memory allocation failure when defining a new lambda |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4075 func Test_lambda_allocation_failure() |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4076 new |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4077 let lines =<< trim END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4078 vim9script |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4079 g:Xlambda = (x): number => { |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4080 return x + 1 |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4081 } |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4082 END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4083 call setline(1, lines) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4084 call test_alloc_fail(GetAllocId('get_func'), 0, 0) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4085 call assert_fails('source', 'E342:') |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4086 call assert_false(exists('g:Xlambda')) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4087 bw! |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4088 endfunc |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
28173
diff
changeset
|
4089 |
27738
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4090 " The following messes up syntax highlight, keep near the end. |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4091 if has('python3') |
27738
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4092 def Test_python3_command() |
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4093 py3 import vim |
27740
2bd27d5ffbef
patch 8.2.4396: Python3 test fails
Bram Moolenaar <Bram@vim.org>
parents:
27738
diff
changeset
|
4094 py3 vim.command("g:done = 'yes'") |
27738
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4095 assert_equal('yes', g:done) |
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4096 unlet g:done |
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4097 enddef |
d754ac2f5ac5
patch 8.2.4395: some code lines not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
27669
diff
changeset
|
4098 |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4099 def Test_python3_heredoc() |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4100 py3 << trim EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4101 import vim |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4102 vim.vars['didit'] = 'yes' |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4103 EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4104 assert_equal('yes', g:didit) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4105 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4106 python3 << trim EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4107 import vim |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4108 vim.vars['didit'] = 'again' |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4109 EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4110 assert_equal('again', g:didit) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4111 enddef |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4112 endif |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4113 |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4114 if has('lua') |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4115 def Test_lua_heredoc() |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4116 g:d = {} |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4117 lua << trim EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4118 x = vim.eval('g:d') |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4119 x['key'] = 'val' |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4120 EOF |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4121 assert_equal('val', g:d.key) |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4122 enddef |
28154
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4123 |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4124 def Test_lua_heredoc_fails() |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4125 var lines = [ |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4126 'vim9script', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4127 'def ExeLua()', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4128 'lua << trim EOLUA', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4129 "x = vim.eval('g:nodict')", |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4130 'EOLUA', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4131 'enddef', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4132 'ExeLua()', |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4133 ] |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4134 v9.CheckScriptFailure(lines, 'E121: Undefined variable: g:nodict') |
ae975c8d5438
patch 8.2.4601: Vim9: not enough test coverage for executing :def function
Bram Moolenaar <Bram@vim.org>
parents:
28123
diff
changeset
|
4135 enddef |
24826
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4136 endif |
a8d64f1a223b
patch 8.2.2951: Vim9: cannot use heredoc for :python, :lua, etc.
Bram Moolenaar <Bram@vim.org>
parents:
24776
diff
changeset
|
4137 |
20257
683c2da4982b
patch 8.2.0684: Vim9: memory leak when using lambda
Bram Moolenaar <Bram@vim.org>
parents:
20255
diff
changeset
|
4138 |
19912
d4fa9db88d16
patch 8.2.0512: Vim9: no optional arguments in func type
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4139 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |