annotate src/testdir/test_nested_function.vim @ 31047:ac1f548223a5 v9.0.0858

patch 9.0.0858: "!!sort" in a closed fold sorts too many lines Commit: https://github.com/vim/vim/commit/f00112d558eb9a7d1d5413c096960ddcc52c9f66 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 11 01:20:35 2022 +0000 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines Problem: "!!sort" in a closed fold sorts too many lines. Solution: Round to end of fold after adding the line count. (closes https://github.com/vim/vim/issues/11487)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Nov 2022 02:30:03 +0100
parents 08940efa6b4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
1 " Tests for nested functions
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
2
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
3 source check.vim
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
4
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
5 func NestedFunc()
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
6 func! Func1()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 let g:text .= 'Func1 '
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
8 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 call Func1()
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
10 func! s:func2()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 let g:text .= 's:func2 '
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
12 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 call s:func2()
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
14 func! s:_func3()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 let g:text .= 's:_func3 '
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
16 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 call s:_func3()
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let fn = 'Func4'
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
19 func! {fn}()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 let g:text .= 'Func4 '
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
21 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 call {fn}()
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 let fn = 'func5'
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
24 func! s:{fn}()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let g:text .= 's:func5'
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
26 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 call s:{fn}()
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
28 endfunc
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
30 func Test_nested_functions()
10068
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 let g:text = ''
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 call NestedFunc()
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 call assert_equal('Func1 s:func2 s:_func3 Func4 s:func5', g:text)
c577c6a2e88b commit https://github.com/vim/vim/commit/19a1669ffc796e30a83c5600f82f12ebf63a2261
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 endfunction
10381
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
35
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
36 func Test_nested_argument()
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
37 func g:X()
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
38 let g:Y = function('sort')
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
39 endfunc
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
40 let g:Y = function('sort')
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
41 echo g:Y([], g:X())
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
42 delfunc g:X
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
43 unlet g:Y
14a82c6433be commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924
Christian Brabandt <cb@256bit.org>
parents: 10068
diff changeset
44 endfunc
10488
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
45
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
46 func Recurse(count)
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
47 if a:count > 0
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
48 call Recurse(a:count - 1)
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
49 endif
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
50 endfunc
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
51
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
52 func Test_max_nesting()
10496
bd5bec6291cc commit https://github.com/vim/vim/commit/269aec7e615b7710139a69a4c715dfe534aa3a1a
Christian Brabandt <cb@256bit.org>
parents: 10488
diff changeset
53 " TODO: why does this fail on Windows? Runs out of stack perhaps?
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
54 CheckNotMSWindows
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
55
10488
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
56 let call_depth_here = 2
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
57 let ex_depth_here = 5
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
58 set mfd&
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
59
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
60 call Recurse(99 - call_depth_here)
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
61 call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:')
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
62
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
63 set mfd=210
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
64 call Recurse(209 - ex_depth_here)
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
65 call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:')
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
66
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
67 set mfd&
89200fa1d174 commit https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1
Christian Brabandt <cb@256bit.org>
parents: 10381
diff changeset
68 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
69
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 10496
diff changeset
70 " vim: shiftwidth=2 sts=2 expandtab