aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKillTheMule <KillTheMule@users.noreply.github.com>2016-04-16 17:48:45 +0200
committerKillTheMule <KillTheMule@users.noreply.github.com>2016-05-08 20:15:07 +0200
commit65b74998723867c03683de8c6b71b5a71b5a7c59 (patch)
treeed49b0a22bff3abcb174f96dca8f5e05eaa54a5d
parentdc913974638af5ba4b0d76bcb3b0efd838bf30a1 (diff)
downloadrneovim-65b74998723867c03683de8c6b71b5a71b5a7c59.tar.gz
rneovim-65b74998723867c03683de8c6b71b5a71b5a7c59.tar.bz2
rneovim-65b74998723867c03683de8c6b71b5a71b5a7c59.zip
vim-patch:cb00f03
Add missing test file. https://github.com/vim/vim/commit/cb00f039332d3188931035e9d07144546fdea78a Converted to a lua test. Change the tolerance of the test to avoid false positives on travis.
-rw-r--r--test/functional/eval/reltime_spec.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/functional/eval/reltime_spec.lua b/test/functional/eval/reltime_spec.lua
new file mode 100644
index 0000000000..da55a3fac3
--- /dev/null
+++ b/test/functional/eval/reltime_spec.lua
@@ -0,0 +1,36 @@
+local helpers = require('test.functional.helpers')
+local clear, eq, ok = helpers.clear, helpers.eq, helpers.ok
+local neq, execute, funcs = helpers.neq, helpers.execute, helpers.funcs
+local reltime, reltimestr, reltimefloat = funcs.reltime, funcs.reltimestr, funcs.reltimefloat
+
+describe('reltimestr(), reltimefloat()', function()
+ before_each(clear)
+
+ it('Checks', function()
+ local now = reltime()
+ execute('sleep 10m')
+ local later = reltime()
+ local elapsed = reltime(now)
+
+ neq(reltimestr(elapsed), '0.0')
+ ok(reltimefloat(elapsed) > 0.0)
+ -- original vim test for < 0.1, but easily fails on travis
+ ok(nil ~= string.match(reltimestr(elapsed), "0%."))
+ ok(reltimefloat(elapsed) < 1.0)
+
+ local same = reltime(now, now)
+ local samestr = string.gsub(reltimestr(same), ' ', '')
+ samestr = string.sub(samestr, 1, 5)
+
+ eq('0.000', samestr)
+ eq(0.0, reltimefloat(same))
+
+ local differs = reltime(now, later)
+ neq(reltimestr(differs), '0.0')
+ ok(reltimefloat(differs) > 0.0)
+ -- original vim test for < 0.1, but easily fails on travis
+ ok(nil ~= string.match(reltimestr(differs), "0%."))
+ ok(reltimefloat(differs) < 1.0)
+
+ end)
+end)