Mercurial > vim
diff src/testdir/test_profile.vim @ 23976:03819ebd3e6d v8.2.2530
patch 8.2.2530: Vim9: not enough testing for profiling
Commit: https://github.com/vim/vim/commit/12d265315fac9e4f3436c38a87f6d9a23b9e7e2b
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 19 19:13:21 2021 +0100
patch 8.2.2530: Vim9: not enough testing for profiling
Problem: Vim9: not enough testing for profiling.
Solution: Add a test with nested functions and a lambda. Fix profiling
for calling a compiled function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 19 Feb 2021 19:15:03 +0100 |
parents | 9b55c60f9d52 |
children | 15408ab5fed7 |
line wrap: on
line diff
--- a/src/testdir/test_profile.vim +++ b/src/testdir/test_profile.vim @@ -605,5 +605,38 @@ func Test_vim9_profiling() call delete('Xprofile_crash.log') endfunc +func Test_vim9_nested_call() + let lines =<< trim END + vim9script + var total = 0 + def One(Ref: func(number)) + for i in range(3) + Ref(i) + endfor + enddef + def Two(nr: number) + total += nr + enddef + prof start Xprofile_nested.log + prof func One + prof func Two + One((nr) => Two(nr)) + assert_equal(3, total) + END + call writefile(lines, 'Xprofile_nested.vim') + call system(GetVimCommandClean() . ' -es -c "so Xprofile_nested.vim" -c q') + call assert_equal(0, v:shell_error) + + let prof_lines = readfile('Xprofile_nested.log')->join('#') + call assert_match('FUNCTION <SNR>\d\+_One().*' + \ .. '#Called 1 time.*' + \ .. '# 1 \s*[0-9.]\+ for i in range(3)' + \ .. '# 3 \s*[0-9.]\+ \s*[0-9.]\+ Ref(i)' + \ .. '# 3 \s*[0-9.]\+ endfor', prof_lines) + call assert_match('FUNCTION <SNR>\d\+_Two().*' + \ .. '#Called 3 times.*' + \ .. '# 3 \s*[0-9.]\+ total += nr', prof_lines) +endfunc + " vim: shiftwidth=2 sts=2 expandtab