Mercurial > vim
changeset 17480:91cac682b09a v8.1.1738
patch 8.1.1738: testing lambda with timer is slow
commit https://github.com/vim/vim/commit/9bc4dde45d45df732953491d0f2c3fd3b10a627e
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 24 13:08:29 2019 +0200
patch 8.1.1738: testing lambda with timer is slow
Problem: Testing lambda with timer is slow.
Solution: Do not test timer accuracy, only that it works. (Daniel Hahler,
closes #4723)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 24 Jul 2019 13:15:06 +0200 |
parents | 35b73ec0ba25 |
children | 0cd89bb4dfa8 |
files | src/testdir/test_lambda.vim src/version.c |
diffstat | 2 files changed, 21 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_lambda.vim +++ b/src/testdir/test_lambda.vim @@ -26,20 +26,32 @@ func Test_lambda_with_timer() let s:n = 0 let s:timer_id = 0 func! s:Foo() - "let n = 0 - let s:timer_id = timer_start(50, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1}) + let s:timer_id = timer_start(10, {-> execute("let s:n += 1 | echo s:n", "")}, {"repeat": -1}) endfunc call s:Foo() - sleep 200ms + " check timer works + for i in range(0, 10) + if s:n > 0 + break + endif + sleep 10m + endfor + " do not collect lambda call test_garbagecollect_now() + + " check timer still works let m = s:n - sleep 200ms + for i in range(0, 10) + if s:n > m + break + endif + sleep 10m + endfor + call timer_stop(s:timer_id) - call assert_true(m > 1) - call assert_true(s:n > m + 1) - call assert_true(s:n < 9) + call assert_true(s:n > m) endfunc func Test_lambda_with_partial()