]> granicus.if.org Git - vim/commitdiff
patch 8.1.1738: testing lambda with timer is slow v8.1.1738
authorBram Moolenaar <Bram@vim.org>
Wed, 24 Jul 2019 11:08:29 +0000 (13:08 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 24 Jul 2019 11:08:29 +0000 (13:08 +0200)
Problem:    Testing lambda with timer is slow.
Solution:   Do not test timer accuracy, only that it works. (Daniel Hahler,
            closes #4723)

src/testdir/test_lambda.vim
src/version.c

index 4ff3e20f1384664be00318dad71c547a92ed4fc5..7689219955236896ec56d7f4be13b1acf98709c8 100644 (file)
@@ -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()
index 96f4bce893c9b3fdcc299813f3ed4b1ae19035fe..9eb1e13759db94612d35ab750dc2afade3113323 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1738,
 /**/
     1737,
 /**/