aboutsummaryrefslogtreecommitdiff
path: root/spec/time_spec.lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2023-11-15 19:28:06 +0100
committerGitHub <noreply@github.com>2023-11-15 19:28:06 +0100
commit90997893cc568c86805afa95db28439c28e32980 (patch)
tree4a692fcc91a811e18023ba1896aeee23fe2ee2c5 /spec/time_spec.lua
parentf868c16514be69b20a4e771cc347a80c9c439db6 (diff)
parent048f3cec7a18e7a28146f03c3c9e5d89d9613028 (diff)
downloadluasystem-90997893cc568c86805afa95db28439c28e32980.tar.gz
luasystem-90997893cc568c86805afa95db28439c28e32980.tar.bz2
luasystem-90997893cc568c86805afa95db28439c28e32980.zip
Merge pull request #6 from lunarmodules/time
Diffstat (limited to 'spec/time_spec.lua')
-rw-r--r--spec/time_spec.lua31
1 files changed, 0 insertions, 31 deletions
diff --git a/spec/time_spec.lua b/spec/time_spec.lua
deleted file mode 100644
index a017cfe..0000000
--- a/spec/time_spec.lua
+++ /dev/null
@@ -1,31 +0,0 @@
1local system = require 'system.core'
2
3describe('Test time functions', function()
4 it('gettime returns current time', function()
5 local starttime = system.gettime()
6 local expected = os.time()
7 local endtime = system.gettime()
8 local delta = endtime - starttime
9 local avg = starttime + delta/2
10 assert.is_true(expected >= math.floor(starttime))
11 assert.is_true(expected <= math.ceil(endtime))
12 assert.is_near(expected, avg, 1 + delta)
13 end)
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
24 it('sleep will wait for specified amount of time', function()
25 local starttime = system.gettime()
26 local starttick = system.monotime()
27 system.sleep(0.5)
28 assert.is_near(0.5, system.gettime() - starttime, 0.15)
29 assert.is_near(0.5, system.monotime() - starttick, 0.15)
30 end)
31end)