Mercurial > vim
annotate src/testdir/test_user_func.vim @ 17241:3ada3d207b33 v8.1.1620
patch 8.1.1620: no test for popup window with border and mask
commit https://github.com/vim/vim/commit/ba45f1f4fbff1a78ed5786c2608b0f8a76ec53c8
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 3 22:50:41 2019 +0200
patch 8.1.1620: no test for popup window with border and mask
Problem: No test for popup window with border and mask.
Solution: Add this popup window, fix problems.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 03 Jul 2019 23:00:09 +0200 |
parents | 1a911bd57f11 |
children | 9ffec4eb8d33 |
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 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 func Table(title, ...) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 let ret = a:title |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 let idx = 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 while idx <= a:0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 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
|
11 let idx = idx + 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endwhile |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 return ret |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 func Compute(n1, n2, divname) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 if a:n2 == 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 return "fail" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 endif |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 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
|
21 return "ok" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 func Expr1() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 silent! normal! v |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 return "111" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 func Expr2() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 call search('XX', 'b') |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 return "222" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 func ListItem() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 let g:counter += 1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 return g:counter . '. ' |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 func ListReset() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 let g:counter = 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 return '' |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 func FuncWithRef(a) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 unlet g:FuncRef |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 return a:a |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 endfunc |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 func Test_user_func() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 let g:FuncRef=function("FuncWithRef") |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 let g:counter = 0 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 inoremap <expr> ( ListItem() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 inoremap <expr> [ ListReset() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 imap <expr> + Expr1() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 imap <expr> * Expr2() |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 let g:retval = "nop" |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 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
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 enew |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 normal oXX+-XX |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 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
|
69 normal o---*--- |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 call assert_equal('---222---', getline('.')) |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 normal o(one |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 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
|
73 normal o(two |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 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
|
75 normal o[(one again |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 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
|
77 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 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
|
79 call assert_fails("call extend(g:, {'max': function('min')})", 'E704') |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 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
|
81 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 " 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
|
83 " 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
|
84 " rhs of &&. |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
85 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
|
86 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
|
87 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
88 delfunc Table |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 delfunc Compute |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 delfunc Expr1 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 delfunc Expr2 |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 delfunc ListItem |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 delfunc ListReset |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 unlet g:retval g:counter |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 enew! |
15f0f9f16cd9
patch 8.0.1209: still too many old style tests
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 endfunc |
16615
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
97 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
98 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
|
99 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
|
100 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
101 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
102 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
|
103 return deepcopy(a:) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
104 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
105 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
106 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
|
107 return deepcopy(a:) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
108 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
109 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
110 func MakeBadFunc() |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
111 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
|
112 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
113 endfunc |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
114 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
115 func Test_default_arg() |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
116 call assert_equal(1.0, Log(10)) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
117 call assert_equal(log(10), Log(10, exp(1))) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
118 call assert_fails("call Log(1,2,3)", 'E118') |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
119 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
120 let res = Args(1) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
121 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
|
122 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
|
123 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
|
124 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 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
|
129 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
135 call assert_fails("call MakeBadFunc()", 'E989') |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
136 call assert_fails("fu F(a=1 ,) | endf", 'E475') |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
137 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
138 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
|
139 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
|
140 |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
141 call assert_equal("\n" |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
142 \ .. " 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
|
143 \ .. "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
|
144 \ .. " endfunction", |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
145 \ execute('func Args2')) |
1a911bd57f11
patch 8.1.1310: named function arguments are never optional
Bram Moolenaar <Bram@vim.org>
parents:
12662
diff
changeset
|
146 endfunc |