<commit_before>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)<commit_msg>Make test for `gettime` more robust<commit_after>local system = require 'system.core'

describe('Test time functions', function()
  it('gettime returns current time', function()
    local starttime = system.gettime()
    local expected = os.time()
    local endtime = system.gettime()
    local delta = endtime - starttime
    local avg = starttime + delta/2
    assert.is_true(expected >= math.floor(starttime))
    assert.is_true(expected <= math.ceil(endtime))
    assert.is_near(expected, avg, 1 + delta)
  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)
{'fraction_non_alphanumeric': 0.1307829181494662, 'fraction_numerical': 0.014234875444839857, 'mean_word_length': 3.97787610619469, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612703', 'n_tokens_mistral': 368, 'n_tokens_neox': 354, 'n_words': 98}