Patch 7.4.2240
Problem:    Tests using the sleep time can be flaky.
Solution:   Use reltime() if available. (Partly by Shane Harper)
Files:      src/testdir/shared.vim, src/testdir/test_timers.vim


*** ../vim-7.4.2239/src/testdir/shared.vim      2016-08-08 22:34:10.294536818 
+0200
--- src/testdir/shared.vim      2016-08-22 21:30:05.716370288 +0200
***************
*** 109,127 ****
  endfunc
  
  " Wait for up to a second for "expr" to become true.
! " Return time slept in milliseconds.
  func WaitFor(expr)
!   let slept = 0
    for i in range(100)
      try
        if eval(a:expr)
        return slept
        endif
      catch
      endtry
!     let slept += 10
      sleep 10m
    endfor
  endfunc
  
  " Run Vim, using the "vimcmd" file and "-u NORC".
--- 109,139 ----
  endfunc
  
  " Wait for up to a second for "expr" to become true.
! " Return time slept in milliseconds.  With the +reltime feature this can be
! " more than the actual waiting time.  Without +reltime it can also be less.
  func WaitFor(expr)
!   " using reltime() is more accurate, but not always available
!   if has('reltime')
!     let start = reltime()
!   else
!     let slept = 0
!   endif
    for i in range(100)
      try
        if eval(a:expr)
+       if has('reltime')
+         return float2nr(reltimefloat(reltime(start)) * 1000)
+       endif
        return slept
        endif
      catch
      endtry
!     if !has('reltime')
!       let slept += 10
!     endif
      sleep 10m
    endfor
+   return 1000
  endfunc
  
  " Run Vim, using the "vimcmd" file and "-u NORC".
*** ../vim-7.4.2239/src/testdir/test_timers.vim 2016-08-18 23:04:44.666592772 
+0200
--- src/testdir/test_timers.vim 2016-08-22 21:36:44.248834978 +0200
***************
*** 19,25 ****
    let timer = timer_start(50, 'MyHandler')
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   call assert_inrange(30, 100, slept)
  endfunc
  
  func Test_repeat_three()
--- 19,29 ----
    let timer = timer_start(50, 'MyHandler')
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   if has('reltime')
!     call assert_inrange(50, 100, slept)
!   else
!     call assert_inrange(20, 100, slept)
!   endif
  endfunc
  
  func Test_repeat_three()
***************
*** 27,33 ****
    let timer = timer_start(50, 'MyHandler', {'repeat': 3})
    let slept = WaitFor('g:val == 3')
    call assert_equal(3, g:val)
!   call assert_inrange(80, 200, slept)
  endfunc
  
  func Test_repeat_many()
--- 31,41 ----
    let timer = timer_start(50, 'MyHandler', {'repeat': 3})
    let slept = WaitFor('g:val == 3')
    call assert_equal(3, g:val)
!   if has('reltime')
!     call assert_inrange(150, 200, slept)
!   else
!     call assert_inrange(80, 200, slept)
!   endif
  endfunc
  
  func Test_repeat_many()
***************
*** 48,54 ****
    call timer_start(50, s:meow.bite)
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   call assert_inrange(30, 100, slept)
  endfunc
  
  func Test_retain_partial()
--- 56,66 ----
    call timer_start(50, s:meow.bite)
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   if has('reltime')
!     call assert_inrange(50, 100, slept)
!   else
!     call assert_inrange(20, 100, slept)
!   endif
  endfunc
  
  func Test_retain_partial()
***************
*** 109,115 ****
  
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   call assert_inrange(0, 10, slept)
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
--- 121,131 ----
  
    let slept = WaitFor('g:val == 1')
    call assert_equal(1, g:val)
!   if has('reltime')
!     call assert_inrange(0, 30, slept)
!   else
!     call assert_inrange(0, 10, slept)
!   endif
  endfunc
  
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-7.4.2239/src/version.c       2016-08-21 22:39:30.995567145 +0200
--- src/version.c       2016-08-22 21:31:39.283539901 +0200
***************
*** 765,766 ****
--- 765,768 ----
  {   /* Add new patch number below this line */
+ /**/
+     2240,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
54. You start tilting your head sideways to smile. :-)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui