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.tar.gz luasystem-8c1a0fca53bf11f2b7ce708c8c5bdb05e5a55701.tar.bz2 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() | |||
12 | assert.is_near(expected, avg, 1 + delta) | 12 | assert.is_near(expected, avg, 1 + delta) |
13 | end) | 13 | end) |
14 | 14 | ||
15 | it('monottime returns monotonically increasing time', function() | ||
16 | local starttime = system.monotime() | ||
17 | local endtime = system.monotime() | ||
18 | local delta = endtime - starttime | ||
19 | assert.is_true(starttime > 0) | ||
20 | assert.is_true(delta >= 0) | ||
21 | assert.is_true(system.monotime() - endtime >= 0) | ||
22 | end) | ||
23 | |||
15 | it('sleep will wait for specified amount of time', function() | 24 | it('sleep will wait for specified amount of time', function() |
16 | local starttime = system.gettime() | 25 | local starttime = system.gettime() |
26 | local starttick = system.monotime() | ||
17 | system.sleep(0.5) | 27 | system.sleep(0.5) |
18 | assert.is_near(0.5, system.gettime() - starttime, 0.1) | 28 | assert.is_near(0.5, system.gettime() - starttime, 0.1) |
29 | assert.is_near(0.5, system.monotime() - starttick, 0.1) | ||
19 | end) | 30 | end) |
20 | end) | 31 | end) |