comparison 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
comparison
equal deleted inserted replaced
23975:a1b074b83f39 23976:03819ebd3e6d
603 call CheckScriptSuccess(lines) 603 call CheckScriptSuccess(lines)
604 call delete('Xprofile_crash.vim') 604 call delete('Xprofile_crash.vim')
605 call delete('Xprofile_crash.log') 605 call delete('Xprofile_crash.log')
606 endfunc 606 endfunc
607 607
608 func Test_vim9_nested_call()
609 let lines =<< trim END
610 vim9script
611 var total = 0
612 def One(Ref: func(number))
613 for i in range(3)
614 Ref(i)
615 endfor
616 enddef
617 def Two(nr: number)
618 total += nr
619 enddef
620 prof start Xprofile_nested.log
621 prof func One
622 prof func Two
623 One((nr) => Two(nr))
624 assert_equal(3, total)
625 END
626 call writefile(lines, 'Xprofile_nested.vim')
627 call system(GetVimCommandClean() . ' -es -c "so Xprofile_nested.vim" -c q')
628 call assert_equal(0, v:shell_error)
629
630 let prof_lines = readfile('Xprofile_nested.log')->join('#')
631 call assert_match('FUNCTION <SNR>\d\+_One().*'
632 \ .. '#Called 1 time.*'
633 \ .. '# 1 \s*[0-9.]\+ for i in range(3)'
634 \ .. '# 3 \s*[0-9.]\+ \s*[0-9.]\+ Ref(i)'
635 \ .. '# 3 \s*[0-9.]\+ endfor', prof_lines)
636 call assert_match('FUNCTION <SNR>\d\+_Two().*'
637 \ .. '#Called 3 times.*'
638 \ .. '# 3 \s*[0-9.]\+ total += nr', prof_lines)
639 endfunc
640
608 641
609 " vim: shiftwidth=2 sts=2 expandtab 642 " vim: shiftwidth=2 sts=2 expandtab