Mercurial > vim
annotate src/testdir/test_user_func.vim @ 30693:a59a8ce13129 v9.0.0681
patch 9.0.0681: "<<<" shows for 'smoothscroll' even when 'showbreak is set
Commit: https://github.com/vim/vim/commit/0937b9fb244949b7ce9bfcf8398d7495b9b6aa85
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 6 21:24:34 2022 +0100
patch 9.0.0681: "<<<" shows for 'smoothscroll' even when 'showbreak is set
Problem: "<<<" shows for 'smoothscroll' even when 'showbreak is set.
Solution: When 'showbreak' is set do not display "<<<".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 06 Oct 2022 22:30:03 +0200 |
parents | 029c59bf78f1 |
children | 0913cd44fdfa |
rev | line source |
---|---|
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for user functions. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Also test an <expr> mapping calling a function. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Also test that a builtin function cannot be replaced. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " Also test for regression when calling arbitrary expression. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
6 source check.vim |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
7 source shared.vim |
30166
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
8 import './vim9.vim' as v9 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
9 |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 func Table(title, ...) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 let ret = a:title |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 let idx = 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 while idx <= a:0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 exe "let ret = ret . a:" . idx |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 let idx = idx + 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 endwhile |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 return ret |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 func Compute(n1, n2, divname) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 if a:n2 == 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 return "fail" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 endif |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 exe "let g:" . a:divname . " = ". a:n1 / a:n2 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 return "ok" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 func Expr1() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 silent! normal! v |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 return "111" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 func Expr2() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 call search('XX', 'b') |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 return "222" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 func ListItem() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 let g:counter += 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 return g:counter . '. ' |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 func ListReset() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 let g:counter = 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 return '' |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 func FuncWithRef(a) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 unlet g:FuncRef |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 return a:a |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 func Test_user_func() |
17638
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
54 let g:FuncRef = function("FuncWithRef") |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 let g:counter = 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 inoremap <expr> ( ListItem() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 inoremap <expr> [ ListReset() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 imap <expr> + Expr1() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 imap <expr> * Expr2() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 let g:retval = "nop" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 call assert_equal('xxx4asdf', Table("xxx", 4, "asdf")) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 call assert_equal('fail', Compute(45, 0, "retval")) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 call assert_equal('nop', g:retval) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 call assert_equal('ok', Compute(45, 5, "retval")) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 call assert_equal(9, g:retval) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 call assert_equal(333, g:FuncRef(333)) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 |
17638
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
69 let g:retval = "nop" |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
70 call assert_equal('xxx4asdf', "xxx"->Table(4, "asdf")) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
71 call assert_equal('fail', 45->Compute(0, "retval")) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
72 call assert_equal('nop', g:retval) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
73 call assert_equal('ok', 45->Compute(5, "retval")) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
74 call assert_equal(9, g:retval) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
75 " call assert_equal(333, 333->g:FuncRef()) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
76 |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 enew |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 normal oXX+-XX |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 call assert_equal('XX111-XX', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
81 normal o---*--- |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 call assert_equal('---222---', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
83 normal o(one |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 call assert_equal('1. one', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 normal o(two |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 call assert_equal('2. two', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 normal o[(one again |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 call assert_equal('1. one again', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
90 " Try to overwrite a function in the global (g:) scope |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 call assert_equal(3, max([1, 2, 3])) |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21124
diff
changeset
|
92 call assert_fails("call extend(g:, {'max': function('min')})", 'E704:') |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 call assert_equal(3, max([1, 2, 3])) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 |
19689
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19419
diff
changeset
|
95 " Try to overwrite an user defined function with a function reference |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19419
diff
changeset
|
96 call assert_fails("let Expr1 = function('min')", 'E705:') |
da98d2ed8dc5
patch 8.2.0401: not enough test coverage for evalvars.c
Bram Moolenaar <Bram@vim.org>
parents:
19419
diff
changeset
|
97 |
12662
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
98 " Regression: the first line below used to throw ?E110: Missing ')'? |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 " Second is here just to prove that this line is correct when not skipping |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 " rhs of &&. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 call assert_equal(0, (0 && (function('tr'))(1, 2, 3))) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 call assert_equal(1, (1 && (function('tr'))(1, 2, 3))) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 delfunc Table |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 delfunc Compute |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 delfunc Expr1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 delfunc Expr2 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 delfunc ListItem |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 delfunc ListReset |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 unlet g:retval g:counter |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 enew! |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 endfunc |
16615
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
113 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
114 func Log(val, base = 10) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
115 return log(a:val) / log(a:base) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
116 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
117 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
118 func Args(mandatory, optional = v:null, ...) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
119 return deepcopy(a:) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
120 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
121 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
122 func Args2(a = 1, b = 2, c = 3) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
123 return deepcopy(a:) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
124 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
125 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
126 func MakeBadFunc() |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
127 func s:fcn(a, b=1, c) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
128 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
129 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
130 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
131 func Test_default_arg() |
30310
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30166
diff
changeset
|
132 call assert_equal(1.0, Log(10)) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30166
diff
changeset
|
133 call assert_equal(log(10), Log(10, exp(1))) |
029c59bf78f1
patch 9.0.0491: no good reason to build without the float feature
Bram Moolenaar <Bram@vim.org>
parents:
30166
diff
changeset
|
134 call assert_fails("call Log(1,2,3)", 'E118:') |
16615
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
135 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
136 let res = Args(1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
137 call assert_equal(res.mandatory, 1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
138 call assert_equal(res.optional, v:null) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
139 call assert_equal(res['0'], 0) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
140 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
141 let res = Args(1,2) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
142 call assert_equal(res.mandatory, 1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
143 call assert_equal(res.optional, 2) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
144 call assert_equal(res['0'], 0) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
145 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
146 let res = Args(1,2,3) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
147 call assert_equal(res.mandatory, 1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
148 call assert_equal(res.optional, 2) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
149 call assert_equal(res['0'], 1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
150 |
22087
ff21e2962490
patch 8.2.1593: tests do not check the error number properly
Bram Moolenaar <Bram@vim.org>
parents:
21124
diff
changeset
|
151 call assert_fails("call MakeBadFunc()", 'E989:') |
24373
da8b8a320bb3
patch 8.2.2727: function test fails
Bram Moolenaar <Bram@vim.org>
parents:
23108
diff
changeset
|
152 call assert_fails("fu F(a=1 ,) | endf", 'E1068:') |
16615
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
153 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
154 let d = Args2(7, v:none, 9) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
155 call assert_equal([7, 2, 9], [d.a, d.b, d.c]) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
156 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
157 call assert_equal("\n" |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
158 \ .. " function Args2(a = 1, b = 2, c = 3)\n" |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
159 \ .. "1 return deepcopy(a:)\n" |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
160 \ .. " endfunction", |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
161 \ execute('func Args2')) |
24695
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
162 |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
163 " Error in default argument expression |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
164 let l =<< trim END |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
165 func F1(x = y) |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
166 return a:x * 2 |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
167 endfunc |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
168 echo F1() |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
169 END |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
170 let @a = l->join("\n") |
13efbfc53054
patch 8.2.2886: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24685
diff
changeset
|
171 call assert_fails("exe @a", 'E121:') |
16615
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
172 endfunc |
17638
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
173 |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
174 func s:addFoo(lead) |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
175 return a:lead .. 'foo' |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
176 endfunc |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
177 |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
178 func Test_user_method() |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
179 eval 'bar'->s:addFoo()->assert_equal('barfoo') |
9ffec4eb8d33
patch 8.1.1816: cannot use a user defined function as a method
Bram Moolenaar <Bram@vim.org>
parents:
16615
diff
changeset
|
180 endfunc |
19419
c6c9d91d8290
patch 8.2.0267: no check for a following cmd when calling a function fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
181 |
c6c9d91d8290
patch 8.2.0267: no check for a following cmd when calling a function fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
182 func Test_failed_call_in_try() |
c6c9d91d8290
patch 8.2.0267: no check for a following cmd when calling a function fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
183 try | call UnknownFunc() | catch | endtry |
c6c9d91d8290
patch 8.2.0267: no check for a following cmd when calling a function fails
Bram Moolenaar <Bram@vim.org>
parents:
19249
diff
changeset
|
184 endfunc |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
185 |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
186 " Test for listing user-defined functions |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
187 func Test_function_list() |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
188 call assert_fails("function Xabc", 'E123:') |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
189 endfunc |
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
190 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
191 " Test for <sfile>, <slnum> in a function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
192 func Test_sfile_in_function() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
193 func Xfunc() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
194 call assert_match('..Test_sfile_in_function\[5]..Xfunc', expand('<sfile>')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
195 call assert_equal('2', expand('<slnum>')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
196 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
197 call Xfunc() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
198 delfunc Xfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
199 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
200 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
201 " Test trailing text after :endfunction {{{1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
202 func Test_endfunction_trailing() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
203 call assert_false(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
204 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
205 exe "func Xtest()\necho 'hello'\nendfunc\nlet done = 'yes'" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
206 call assert_true(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
207 call assert_equal('yes', done) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
208 delfunc Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
209 unlet done |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
210 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
211 exe "func Xtest()\necho 'hello'\nendfunc|let done = 'yes'" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
212 call assert_true(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
213 call assert_equal('yes', done) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
214 delfunc Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
215 unlet done |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
216 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
217 " trailing line break |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
218 exe "func Xtest()\necho 'hello'\nendfunc\n" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
219 call assert_true(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
220 delfunc Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
221 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
222 set verbose=1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
223 exe "func Xtest()\necho 'hello'\nendfunc \" garbage" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
224 call assert_notmatch('W22:', split(execute('1messages'), "\n")[0]) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
225 call assert_true(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
226 delfunc Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
227 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
228 exe "func Xtest()\necho 'hello'\nendfunc garbage" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
229 call assert_match('W22:', split(execute('1messages'), "\n")[0]) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
230 call assert_true(exists('*Xtest')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
231 delfunc Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
232 set verbose=0 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
233 |
21124
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
234 func Xtest(a1, a2) |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
235 echo a:a1 .. a:a2 |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
236 endfunc |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
237 set verbose=15 |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
238 redir @a |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
239 call Xtest(123, repeat('x', 100)) |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
240 redir END |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
241 call assert_match('calling Xtest(123, ''xxxxxxx.*x\.\.\.x.*xxxx'')', getreg('a')) |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
242 delfunc Xtest |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
243 set verbose=0 |
8b4b43b5b4c6
patch 8.2.1113: no test for verbose output of :call
Bram Moolenaar <Bram@vim.org>
parents:
19950
diff
changeset
|
244 |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
245 function Foo() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
246 echo 'hello' |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
247 endfunction | echo 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
248 delfunc Foo |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
249 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
250 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
251 func Test_delfunction_force() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
252 delfunc! Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
253 delfunc! Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
254 func Xtest() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
255 echo 'nothing' |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
256 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
257 delfunc! Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
258 delfunc! Xtest |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
259 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
260 " Try deleting the current function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
261 call assert_fails('delfunc Test_delfunction_force', 'E131:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
262 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
263 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
264 func Test_function_defined_line() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
265 CheckNotGui |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
266 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
267 let lines =<< trim [CODE] |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
268 " F1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
269 func F1() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
270 " F2 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
271 func F2() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
272 " |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
273 " |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
274 " |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
275 return |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
276 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
277 " F3 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
278 execute "func F3()\n\n\n\nreturn\nendfunc" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
279 " F4 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
280 execute "func F4()\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
281 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
282 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
283 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
284 \return\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
285 \endfunc" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
286 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
287 " F5 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
288 execute "func F5()\n\n\n\nreturn\nendfunc" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
289 " F6 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
290 execute "func F6()\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
291 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
292 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
293 \\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
294 \return\n |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
295 \endfunc" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
296 call F1() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
297 verbose func F1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
298 verbose func F2 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
299 verbose func F3 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
300 verbose func F4 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
301 verbose func F5 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
302 verbose func F6 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
303 qall! |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
304 [CODE] |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
305 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
306 call writefile(lines, 'Xtest.vim') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
307 let res = system(GetVimCommandClean() .. ' -es -X -S Xtest.vim') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
308 call assert_equal(0, v:shell_error) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
309 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
310 let m = matchstr(res, 'function F1()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
311 call assert_match(' line 2$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
312 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
313 let m = matchstr(res, 'function F2()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
314 call assert_match(' line 4$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
315 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
316 let m = matchstr(res, 'function F3()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
317 call assert_match(' line 11$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
318 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
319 let m = matchstr(res, 'function F4()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
320 call assert_match(' line 13$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
321 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
322 let m = matchstr(res, 'function F5()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
323 call assert_match(' line 21$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
324 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
325 let m = matchstr(res, 'function F6()[^[:print:]]*[[:print:]]*') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
326 call assert_match(' line 23$', m) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
327 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
328 call delete('Xtest.vim') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
329 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
330 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
331 " Test for defining a function reference in the global scope |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
332 func Test_add_funcref_to_global_scope() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
333 let x = g: |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
334 let caught_E862 = 0 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
335 try |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
336 func x.Xfunc() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
337 return 1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
338 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
339 catch /E862:/ |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
340 let caught_E862 = 1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
341 endtry |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
342 call assert_equal(1, caught_E862) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
343 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
344 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
345 func Test_funccall_garbage_collect() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
346 func Func(x, ...) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
347 call add(a:x, a:000) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
348 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
349 call Func([], []) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
350 " Must not crash cause by invalid freeing |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
351 call test_garbagecollect_now() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
352 call assert_true(v:true) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
353 delfunc Func |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
354 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
355 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
356 " Test for script-local function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
357 func <SID>DoLast() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
358 call append(line('$'), "last line") |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
359 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
360 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
361 func s:DoNothing() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
362 call append(line('$'), "nothing line") |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
363 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
364 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
365 func Test_script_local_func() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
366 set nocp nomore viminfo+=nviminfo |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
367 new |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
368 nnoremap <buffer> _x :call <SID>DoNothing()<bar>call <SID>DoLast()<bar>delfunc <SID>DoNothing<bar>delfunc <SID>DoLast<cr> |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
369 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
370 normal _x |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
371 call assert_equal('nothing line', getline(2)) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
372 call assert_equal('last line', getline(3)) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
373 close! |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
374 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
375 " Try to call a script local function in global scope |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
376 let lines =<< trim [CODE] |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
377 :call assert_fails('call s:Xfunc()', 'E81:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
378 :call assert_fails('let x = call("<SID>Xfunc", [])', 'E120:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
379 :call writefile(v:errors, 'Xresult') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
380 :qall |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
381 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
382 [CODE] |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
383 call writefile(lines, 'Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
384 if RunVim([], [], '-s Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
385 call assert_equal([], readfile('Xresult')) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
386 endif |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
387 call delete('Xresult') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
388 call delete('Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
389 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
390 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
391 " Test for errors in defining new functions |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
392 func Test_func_def_error() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
393 call assert_fails('func Xfunc abc ()', 'E124:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
394 call assert_fails('func Xfunc(', 'E125:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
395 call assert_fails('func xfunc()', 'E128:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
396 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
397 " Try to redefine a function that is in use |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
398 let caught_E127 = 0 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
399 try |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
400 func! Test_func_def_error() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
401 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
402 catch /E127:/ |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
403 let caught_E127 = 1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
404 endtry |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
405 call assert_equal(1, caught_E127) |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
406 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
407 " Try to define a function in a dict twice |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
408 let d = {} |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
409 let lines =<< trim END |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
410 func d.F1() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
411 return 1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
412 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
413 END |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
414 let l = join(lines, "\n") . "\n" |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
415 exe l |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
416 call assert_fails('exe l', 'E717:') |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
417 call assert_fails('call feedkeys(":func d.F1()\<CR>", "xt")', 'E717:') |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
418 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
419 " Define an autoload function with an incorrect file name |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
420 call writefile(['func foo#Bar()', 'return 1', 'endfunc'], 'Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
421 call assert_fails('source Xscript', 'E746:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
422 call delete('Xscript') |
22375
595ea7f099cd
patch 8.2.1736: failure to compile a pattern not tested much
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
423 |
595ea7f099cd
patch 8.2.1736: failure to compile a pattern not tested much
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
424 " Try to list functions using an invalid search pattern |
595ea7f099cd
patch 8.2.1736: failure to compile a pattern not tested much
Bram Moolenaar <Bram@vim.org>
parents:
22087
diff
changeset
|
425 call assert_fails('function /\%(/', 'E53:') |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
426 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
427 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
428 " Test for deleting a function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
429 func Test_del_func() |
26757
3a2b222107a6
patch 8.2.3907: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents:
25745
diff
changeset
|
430 call assert_fails('delfunction Xabc', 'E117:') |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
431 let d = {'a' : 10} |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
432 call assert_fails('delfunc d.a', 'E718:') |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
433 func d.fn() |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
434 return 1 |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
435 endfunc |
25745
b916d59f259f
patch 8.2.3408: can delete a numbered function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
436 |
b916d59f259f
patch 8.2.3408: can delete a numbered function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
437 " cannot delete the dict function by number |
b916d59f259f
patch 8.2.3408: can delete a numbered function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
438 let nr = substitute(execute('echo d'), '.*function(''\(\d\+\)'').*', '\1', '') |
b916d59f259f
patch 8.2.3408: can delete a numbered function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
439 call assert_fails('delfunction g:' .. nr, 'E475: Invalid argument: g:') |
b916d59f259f
patch 8.2.3408: can delete a numbered function
Bram Moolenaar <Bram@vim.org>
parents:
24695
diff
changeset
|
440 |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
441 delfunc d.fn |
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
442 call assert_equal({'a' : 10}, d) |
19950
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
443 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
444 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
445 " Test for calling return outside of a function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
446 func Test_return_outside_func() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
447 call writefile(['return 10'], 'Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
448 call assert_fails('source Xscript', 'E133:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
449 call delete('Xscript') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
450 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
451 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
452 " Test for errors in calling a function |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
453 func Test_func_arg_error() |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
454 " Too many arguments |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
455 call assert_fails("call call('min', range(1,20))", 'E118:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
456 call assert_fails("call call('min', range(1,21))", 'E699:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
457 call assert_fails('echo min(0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9,0,1)', |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
458 \ 'E740:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
459 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
460 " Missing dict argument |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
461 func Xfunc() dict |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
462 return 1 |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
463 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
464 call assert_fails('call Xfunc()', 'E725:') |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
465 delfunc Xfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
466 endfunc |
9cbe3a4f1492
patch 8.2.0531: various errors not tested
Bram Moolenaar <Bram@vim.org>
parents:
19932
diff
changeset
|
467 |
23108
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
468 func Test_func_dict() |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
469 let mydict = {'a': 'b'} |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
470 function mydict.somefunc() dict |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
471 return len(self) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
472 endfunc |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
473 |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
474 call assert_equal("{'a': 'b', 'somefunc': function('3')}", string(mydict)) |
23108
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
475 call assert_equal(2, mydict.somefunc()) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
476 call assert_match("^\n function \\d\\\+() dict" |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
477 \ .. "\n1 return len(self)" |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
478 \ .. "\n endfunction$", execute('func mydict.somefunc')) |
24685
04205b7d67d5
patch 8.2.2881: various pieces of code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
24373
diff
changeset
|
479 call assert_fails('call mydict.nonexist()', 'E716:') |
23108
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
480 endfunc |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
481 |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
482 func Test_func_range() |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
483 new |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
484 call setline(1, range(1, 8)) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
485 func FuncRange() range |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
486 echo a:firstline |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
487 echo a:lastline |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
488 endfunc |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
489 3 |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
490 call assert_equal("\n3\n3", execute('call FuncRange()')) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
491 call assert_equal("\n4\n6", execute('4,6 call FuncRange()')) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
492 call assert_equal("\n function FuncRange() range" |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
493 \ .. "\n1 echo a:firstline" |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
494 \ .. "\n2 echo a:lastline" |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
495 \ .. "\n endfunction", |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
496 \ execute('function FuncRange')) |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
497 |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
498 bwipe! |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
499 endfunc |
34a74f5f0fb4
patch 8.2.2100: insufficient testing for function range and dict
Bram Moolenaar <Bram@vim.org>
parents:
22375
diff
changeset
|
500 |
28382
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
501 " Test for memory allocation failure when defining a new function |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
502 func Test_funcdef_alloc_failure() |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
503 new |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
504 let lines =<< trim END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
505 func Xtestfunc() |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
506 return 321 |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
507 endfunc |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
508 END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
509 call setline(1, lines) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
510 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:
26757
diff
changeset
|
511 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:
26757
diff
changeset
|
512 call assert_false(exists('*Xtestfunc')) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
513 call assert_fails('delfunc Xtestfunc', 'E117:') |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
514 %d _ |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
515 let lines =<< trim END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
516 def g:Xvim9func(): number |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
517 return 456 |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
518 enddef |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
519 END |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
520 call setline(1, lines) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
521 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:
26757
diff
changeset
|
522 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:
26757
diff
changeset
|
523 call assert_false(exists('*Xvim9func')) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
524 "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:
26757
diff
changeset
|
525 "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:
26757
diff
changeset
|
526 "call assert_false(exists('*Xtestfunc')) |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
527 "call assert_fails('delfunc Xtestfunc', 'E117:') |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
528 bw! |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
529 endfunc |
f24d4826e6bf
patch 8.2.4716: memory allocation failure not tested when defining a function
Bram Moolenaar <Bram@vim.org>
parents:
26757
diff
changeset
|
530 |
30108
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
531 func AddDefer(arg1, ...) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
532 call extend(g:deferred, [a:arg1]) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
533 if a:0 == 1 |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
534 call extend(g:deferred, [a:1]) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
535 endif |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
536 endfunc |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
537 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
538 func WithDeferTwo() |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
539 call extend(g:deferred, ['in Two']) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
540 for nr in range(3) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
541 defer AddDefer('Two' .. nr) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
542 endfor |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
543 call extend(g:deferred, ['end Two']) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
544 endfunc |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
545 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
546 func WithDeferOne() |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
547 call extend(g:deferred, ['in One']) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
548 call writefile(['text'], 'Xfuncdefer') |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
549 defer delete('Xfuncdefer') |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
550 defer AddDefer('One') |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
551 call WithDeferTwo() |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
552 call extend(g:deferred, ['end One']) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
553 endfunc |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
554 |
30108
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
555 func WithPartialDefer() |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
556 call extend(g:deferred, ['in Partial']) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
557 let Part = funcref('AddDefer', ['arg1']) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
558 defer Part("arg2") |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
559 call extend(g:deferred, ['end Partial']) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
560 endfunc |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
561 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
562 func Test_defer() |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
563 let g:deferred = [] |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
564 call WithDeferOne() |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
565 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
566 call assert_equal(['in One', 'in Two', 'end Two', 'Two2', 'Two1', 'Two0', 'end One', 'One'], g:deferred) |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
567 unlet g:deferred |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
568 |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
569 call assert_equal('', glob('Xfuncdefer')) |
30108
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
570 |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
571 call assert_fails('defer delete("Xfuncdefer")->Another()', 'E488:') |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
572 call assert_fails('defer delete("Xfuncdefer").member', 'E488:') |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
573 |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
574 let g:deferred = [] |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
575 call WithPartialDefer() |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
576 call assert_equal(['in Partial', 'end Partial', 'arg1', 'arg2'], g:deferred) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
577 unlet g:deferred |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
578 |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
579 let Part = funcref('AddDefer', ['arg1'], {}) |
0352577f1ba5
patch 9.0.0390: cannot use a partial with :defer
Bram Moolenaar <Bram@vim.org>
parents:
30065
diff
changeset
|
580 call assert_fails('defer Part("arg2")', 'E1300:') |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
581 endfunc |
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
582 |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
583 func DeferLevelTwo() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
584 call writefile(['text'], 'XDeleteTwo', 'D') |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
585 throw 'someerror' |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
586 endfunc |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
587 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
588 def DeferLevelOne() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
589 call writefile(['text'], 'XDeleteOne', 'D') |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
590 call g:DeferLevelTwo() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
591 enddef |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
592 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
593 func Test_defer_throw() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
594 let caught = 'no' |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
595 try |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
596 call DeferLevelOne() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
597 catch /someerror/ |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
598 let caught = 'yes' |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
599 endtry |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
600 call assert_equal('yes', caught) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
601 call assert_false(filereadable('XDeleteOne')) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
602 call assert_false(filereadable('XDeleteTwo')) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
603 endfunc |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
604 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
605 func Test_defer_quitall() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
606 let lines =<< trim END |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
607 vim9script |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
608 func DeferLevelTwo() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
609 call writefile(['text'], 'XQuitallTwo', 'D') |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
610 qa! |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
611 endfunc |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
612 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
613 def DeferLevelOne() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
614 call writefile(['text'], 'XQuitallOne', 'D') |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
615 call DeferLevelTwo() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
616 enddef |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
617 |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
618 DeferLevelOne() |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
619 END |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
620 call writefile(lines, 'XdeferQuitall', 'D') |
30166
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
621 let res = system(GetVimCommand() .. ' -X -S XdeferQuitall') |
30122
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
622 call assert_equal(0, v:shell_error) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
623 call assert_false(filereadable('XQuitallOne')) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
624 call assert_false(filereadable('XQuitallTwo')) |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
625 endfunc |
458162398682
patch 9.0.0397: :defer not tested with exceptions and ":qa!"
Bram Moolenaar <Bram@vim.org>
parents:
30108
diff
changeset
|
626 |
30140
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
627 func Test_defer_quitall_in_expr_func() |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
628 let lines =<< trim END |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
629 def DefIndex(idx: number, val: string): bool |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
630 call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D') |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
631 if val == 'b' |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
632 qa! |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
633 endif |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
634 return val == 'c' |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
635 enddef |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
636 |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
637 def Test_defer_in_funcref() |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
638 assert_equal(2, indexof(['a', 'b', 'c'], funcref('g:DefIndex'))) |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
639 enddef |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
640 call Test_defer_in_funcref() |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
641 END |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
642 call writefile(lines, 'XdeferQuitallExpr', 'D') |
30166
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
643 let res = system(GetVimCommand() .. ' -X -S XdeferQuitallExpr') |
30140
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
644 call assert_equal(0, v:shell_error) |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
645 call assert_false(filereadable('Xentry0')) |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
646 call assert_false(filereadable('Xentry1')) |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
647 call assert_false(filereadable('Xentry2')) |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
648 endfunc |
3b42bdfff7cb
patch 9.0.0406: deferred functions not invoked when partial func exits
Bram Moolenaar <Bram@vim.org>
parents:
30138
diff
changeset
|
649 |
30126
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
650 func FuncIndex(idx, val) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
651 call writefile([a:idx .. ': ' .. a:val], 'Xentry' .. a:idx, 'D') |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
652 return a:val == 'c' |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
653 endfunc |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
654 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
655 def DefIndex(idx: number, val: string): bool |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
656 call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D') |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
657 return val == 'c' |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
658 enddef |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
659 |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
660 def DefIndexXtra(xtra: string, idx: number, val: string): bool |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
661 call writefile([idx .. ': ' .. val], 'Xentry' .. idx, 'D') |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
662 return val == 'c' |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
663 enddef |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
664 |
30126
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
665 def Test_defer_in_funcref() |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
666 assert_equal(2, indexof(['a', 'b', 'c'], function('g:FuncIndex'))) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
667 assert_false(filereadable('Xentry0')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
668 assert_false(filereadable('Xentry1')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
669 assert_false(filereadable('Xentry2')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
670 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
671 assert_equal(2, indexof(['a', 'b', 'c'], g:DefIndex)) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
672 assert_false(filereadable('Xentry0')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
673 assert_false(filereadable('Xentry1')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
674 assert_false(filereadable('Xentry2')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
675 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
676 assert_equal(2, indexof(['a', 'b', 'c'], function('g:DefIndex'))) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
677 assert_false(filereadable('Xentry0')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
678 assert_false(filereadable('Xentry1')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
679 assert_false(filereadable('Xentry2')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
680 |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
681 assert_equal(2, indexof(['a', 'b', 'c'], funcref(g:DefIndex))) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
682 assert_false(filereadable('Xentry0')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
683 assert_false(filereadable('Xentry1')) |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
684 assert_false(filereadable('Xentry2')) |
30138
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
685 |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
686 assert_equal(2, indexof(['a', 'b', 'c'], function(g:DefIndexXtra, ['xtra']))) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
687 assert_false(filereadable('Xentry0')) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
688 assert_false(filereadable('Xentry1')) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
689 assert_false(filereadable('Xentry2')) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
690 |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
691 assert_equal(2, indexof(['a', 'b', 'c'], funcref(g:DefIndexXtra, ['xtra']))) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
692 assert_false(filereadable('Xentry0')) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
693 assert_false(filereadable('Xentry1')) |
6575d0bf6061
patch 9.0.0405: arguments in a partial not used by a :def function
Bram Moolenaar <Bram@vim.org>
parents:
30126
diff
changeset
|
694 assert_false(filereadable('Xentry2')) |
30126
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
695 enddef |
01408b56f093
patch 9.0.0399: using :defer in expression funcref not tested
Bram Moolenaar <Bram@vim.org>
parents:
30122
diff
changeset
|
696 |
30166
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
697 func Test_defer_wrong_arguments() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
698 call assert_fails('defer delete()', 'E119:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
699 call assert_fails('defer FuncIndex(1)', 'E119:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
700 call assert_fails('defer delete(1, 2, 3)', 'E118:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
701 call assert_fails('defer FuncIndex(1, 2, 3)', 'E118:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
702 |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
703 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
704 def DeferFunc0() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
705 defer delete() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
706 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
707 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
708 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
709 call v9.CheckScriptFailure(lines, 'E119:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
710 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
711 def DeferFunc3() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
712 defer delete(1, 2, 3) |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
713 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
714 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
715 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
716 call v9.CheckScriptFailure(lines, 'E118:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
717 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
718 def DeferFunc2() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
719 defer delete(1, 2) |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
720 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
721 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
722 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
723 call v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
724 |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
725 def g:FuncOneArg(arg: string) |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
726 echo arg |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
727 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
728 |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
729 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
730 def DeferUserFunc0() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
731 defer g:FuncOneArg() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
732 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
733 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
734 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
735 call v9.CheckScriptFailure(lines, 'E119:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
736 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
737 def DeferUserFunc2() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
738 defer g:FuncOneArg(1, 2) |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
739 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
740 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
741 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
742 call v9.CheckScriptFailure(lines, 'E118:') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
743 let lines =<< trim END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
744 def DeferUserFunc1() |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
745 defer g:FuncOneArg(1) |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
746 enddef |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
747 defcompile |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
748 END |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
749 call v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected string but got number') |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
750 endfunc |
d1c04b4dc60d
patch 9.0.0419: the :defer command does not check the function arguments
Bram Moolenaar <Bram@vim.org>
parents:
30140
diff
changeset
|
751 |
30065
6cf788ab844c
patch 9.0.0370: cleaning up afterwards can make a function messy
Bram Moolenaar <Bram@vim.org>
parents:
28382
diff
changeset
|
752 |
19932
2c4d9ca33769
patch 8.2.0522: several errors are not tested for
Bram Moolenaar <Bram@vim.org>
parents:
19689
diff
changeset
|
753 " vim: shiftwidth=2 sts=2 expandtab |