From 7499b422e3f07bf25704cbf7989e845f89697fa8 Mon Sep 17 00:00:00 2001 From: Oscar Lim Date: Sun, 24 Jan 2016 22:53:37 -0800 Subject: Support for gettime and sleep functions Provide `gettime` and `sleep` functions with at least 1 millisecond resolution. --- spec/time_spec.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 spec/time_spec.lua (limited to 'spec') 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) -- cgit v1.2.3-55-g6feb