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.tar.gz luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.tar.bz2 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 @@ | |||
1 | local system = require 'system.core' | ||
2 | |||
3 | describe('Test time functions', function() | ||
4 | it('gettime returns current time', function() | ||
5 | assert.is_near(os.time(), system.gettime(), 1.0) | ||
6 | end) | ||
7 | |||
8 | it('sleep will wait for specified amount of time', function() | ||
9 | local starttime = system.gettime() | ||
10 | system.sleep(0.5) | ||
11 | assert.is_near(0.5, system.gettime() - starttime, 0.1) | ||
12 | end) | ||
13 | end) | ||