test_reltime.vim 907 B

123456789101112131415161718192021222324252627282930313233
  1. " Tests for reltime()
  2. source check.vim
  3. CheckFeature reltime
  4. CheckFeature float
  5. func Test_reltime()
  6. let g:test_is_flaky = 1
  7. let now = reltime()
  8. sleep 10m
  9. let later = reltime()
  10. let elapsed = now->reltime()
  11. call assert_true(reltimestr(elapsed) =~ '0\.0')
  12. call assert_true(elapsed->reltimestr() != '0.0')
  13. call assert_true(reltimefloat(elapsed) < 0.1)
  14. call assert_true(elapsed->reltimefloat() > 0.0)
  15. let same = reltime(now, now)
  16. call assert_equal('0.000', split(reltimestr(same))[0][:4])
  17. call assert_equal(0.0, reltimefloat(same))
  18. let differs = reltime(now, later)
  19. call assert_true(reltimestr(differs) =~ '0\.0')
  20. call assert_true(reltimestr(differs) != '0.0')
  21. call assert_true(reltimefloat(differs) < 0.1)
  22. call assert_true(reltimefloat(differs) > 0.0)
  23. call assert_equal(0, reltime({}))
  24. call assert_equal(0, reltime({}, {}))
  25. endfunc
  26. " vim: shiftwidth=2 sts=2 expandtab