diff options
author | Oscar Lim <olim@ucla.edu> | 2016-01-24 22:53:37 -0800 |
---|---|---|
committer | Oscar Lim <olim@ucla.edu> | 2016-02-10 23:45:49 -0800 |
commit | 7499b422e3f07bf25704cbf7989e845f89697fa8 (patch) | |
tree | 524d8a262a9d61486b858e70c64f8aedbda43095 /spec | |
download | luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.zip |
Support for gettime and sleep functions
Provide `gettime` and `sleep` functions with at least 1 millisecond
resolution.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/time_spec.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/time_spec.lua b/spec/time_spec.lua new file mode 100644 index 0000000..8bee5f7 --- /dev/null +++ b/spec/time_spec.lua @@ -0,0 +1,13 @@ +local system = require 'system.core' + +describe('Test time functions', function() + it('gettime returns current time', function() + assert.is_near(os.time(), system.gettime(), 1.0) + end) + + it('sleep will wait for specified amount of time', function() + local starttime = system.gettime() + system.sleep(0.5) + assert.is_near(0.5, system.gettime() - starttime, 0.1) + end) +end) |