aboutsummaryrefslogtreecommitdiff
path: root/test/unit/os/time.moon
blob: e963f6e2533f274a38cb4a5bf98510bd16094e96 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{time: lua_time} = require 'os'
{:cimport, :eq} = require 'test.unit.helpers'

time = cimport './src/os/time.h'

describe 'time function', ->
  setup ->
    time.time_init!

  describe 'mch_delay', ->
    mch_delay = (ms) ->
      time.mch_delay ms, false

    it 'sleeps at least the number of requested milliseconds', ->
      curtime = lua_time!
      mch_delay 1000
      ellapsed = lua_time! - curtime
      eq true, ellapsed >= 1 and ellapsed <=2