2019-08-30 09:47:42 -07:00
|
|
|
" Tests for reltime()
|
|
|
|
|
2022-07-07 17:26:25 -07:00
|
|
|
source check.vim
|
|
|
|
CheckFeature reltime
|
|
|
|
CheckFeature float
|
2019-08-30 09:47:42 -07:00
|
|
|
|
|
|
|
func Test_reltime()
|
2023-08-21 00:30:20 -07:00
|
|
|
let g:test_is_flaky = 1
|
2019-08-30 09:47:42 -07:00
|
|
|
let now = reltime()
|
|
|
|
sleep 10m
|
|
|
|
let later = reltime()
|
2021-09-01 05:40:58 -07:00
|
|
|
let elapsed = now->reltime()
|
2019-08-30 09:47:42 -07:00
|
|
|
call assert_true(reltimestr(elapsed) =~ '0\.0')
|
2021-09-01 05:40:58 -07:00
|
|
|
call assert_true(elapsed->reltimestr() != '0.0')
|
2019-08-30 09:47:42 -07:00
|
|
|
call assert_true(reltimefloat(elapsed) < 0.1)
|
2021-09-01 05:40:58 -07:00
|
|
|
call assert_true(elapsed->reltimefloat() > 0.0)
|
2019-08-30 09:47:42 -07:00
|
|
|
|
|
|
|
let same = reltime(now, now)
|
|
|
|
call assert_equal('0.000', split(reltimestr(same))[0][:4])
|
|
|
|
call assert_equal(0.0, reltimefloat(same))
|
|
|
|
|
|
|
|
let differs = reltime(now, later)
|
|
|
|
call assert_true(reltimestr(differs) =~ '0\.0')
|
|
|
|
call assert_true(reltimestr(differs) != '0.0')
|
|
|
|
call assert_true(reltimefloat(differs) < 0.1)
|
|
|
|
call assert_true(reltimefloat(differs) > 0.0)
|
|
|
|
|
2022-11-04 16:34:06 -07:00
|
|
|
call assert_equal(0, reltime({}))
|
|
|
|
call assert_equal(0, reltime({}, {}))
|
2019-08-30 09:47:42 -07:00
|
|
|
endfunc
|
2022-11-04 16:34:06 -07:00
|
|
|
|
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|