comparison src/testdir/test_nested_function.vim @ 10381:14a82c6433be v8.0.0085

commit https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Nov 14 21:50:00 2016 +0100 patch 8.0.0085 Problem: Using freed memory with recursive function call. (Dominique Pelle) Solution: Make a copy of the function name.
author Christian Brabandt <cb@256bit.org>
date Mon, 14 Nov 2016 22:00:04 +0100
parents c577c6a2e88b
children 89200fa1d174
comparison
equal deleted inserted replaced
10380:5e502f83c562 10381:14a82c6433be
1 "Tests for nested functions 1 "Tests for nested functions
2 " 2 "
3 function! NestedFunc() 3 func NestedFunc()
4 fu! Func1() 4 func! Func1()
5 let g:text .= 'Func1 ' 5 let g:text .= 'Func1 '
6 endfunction 6 endfunc
7 call Func1() 7 call Func1()
8 fu! s:func2() 8 func! s:func2()
9 let g:text .= 's:func2 ' 9 let g:text .= 's:func2 '
10 endfunction 10 endfunc
11 call s:func2() 11 call s:func2()
12 fu! s:_func3() 12 func! s:_func3()
13 let g:text .= 's:_func3 ' 13 let g:text .= 's:_func3 '
14 endfunction 14 endfunc
15 call s:_func3() 15 call s:_func3()
16 let fn = 'Func4' 16 let fn = 'Func4'
17 fu! {fn}() 17 func! {fn}()
18 let g:text .= 'Func4 ' 18 let g:text .= 'Func4 '
19 endfunction 19 endfunc
20 call {fn}() 20 call {fn}()
21 let fn = 'func5' 21 let fn = 'func5'
22 fu! s:{fn}() 22 func! s:{fn}()
23 let g:text .= 's:func5' 23 let g:text .= 's:func5'
24 endfunction 24 endfunc
25 call s:{fn}() 25 call s:{fn}()
26 endfunction 26 endfunc
27 27
28 function! Test_nested_functions() 28 func Test_nested_functions()
29 let g:text = '' 29 let g:text = ''
30 call NestedFunc() 30 call NestedFunc()
31 call assert_equal('Func1 s:func2 s:_func3 Func4 s:func5', g:text) 31 call assert_equal('Func1 s:func2 s:_func3 Func4 s:func5', g:text)
32 endfunction 32 endfunction
33
34 func Test_nested_argument()
35 func g:X()
36 let g:Y = function('sort')
37 endfunc
38 let g:Y = function('sort')
39 echo g:Y([], g:X())
40 delfunc g:X
41 unlet g:Y
42 endfunc