diff options
author | Oscar Lim <olim@ucla.edu> | 2016-05-07 14:37:25 -0700 |
---|---|---|
committer | Oscar Lim <olim@ucla.edu> | 2016-05-08 16:01:40 -0700 |
commit | 8c1a0fca53bf11f2b7ce708c8c5bdb05e5a55701 (patch) | |
tree | 9624af38c4ba35de244da2281e08049589140e20 /spec | |
parent | 040d7066649ddfcb72424b1cb70d6ad00ea84a21 (diff) | |
download | luasystem-8c1a0fca53bf11f2b7ce708c8c5bdb05e5a55701.zip |
Support for monotime
Provide `monotime` function with at least 1 millisecond resolution.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/time_spec.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/time_spec.lua b/spec/time_spec.lua index c9d3d6d..e1b457a 100644 --- a/spec/time_spec.lua +++ b/spec/time_spec.lua @@ -12,9 +12,20 @@ describe('Test time functions', function() assert.is_near(expected, avg, 1 + delta) end) + it('monottime returns monotonically increasing time', function() + local starttime = system.monotime() + local endtime = system.monotime() + local delta = endtime - starttime + assert.is_true(starttime > 0) + assert.is_true(delta >= 0) + assert.is_true(system.monotime() - endtime >= 0) + end) + it('sleep will wait for specified amount of time', function() local starttime = system.gettime() + local starttick = system.monotime() system.sleep(0.5) assert.is_near(0.5, system.gettime() - starttime, 0.1) + assert.is_near(0.5, system.monotime() - starttick, 0.1) end) end) |