File: reltime_spec.lua

package info (click to toggle)
neovim 0.1.7-4%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 39,060 kB
  • sloc: ansic: 176,052; python: 2,091; awk: 709; sh: 528; perl: 374; makefile: 295; exp: 33; ruby: 8
file content (36 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
local helpers = require('test.functional.helpers')(after_each)
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)