File: posix_sys_time_spec.yaml

package info (click to toggle)
lua-posix 36.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,720 kB
  • sloc: ansic: 5,462; makefile: 21; sh: 6
file content (31 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
before:
  this_module = 'posix.sys.time'
  global_table = '_G'

  M = require(this_module)


specify posix.sys.time:
- before:
     EPOCH = require 'posix.time'.time()

- context when required:
  - it does not touch the global table:
      expect(show_apis {added_to=global_table, by=this_module}).
         to_equal {}


- describe gettimeofday:
  - before:
      gettimeofday = M.gettimeofday

  - context with bad arguments:
      badargs.diagnose(gettimeofday, "()")

  - it returns a PosixTimeval:
      expect(prototype(gettimeofday())).to_be "PosixTimeval"
  - it fetches the current epoch time:
      tv = gettimeofday()
      expect(tv.tv_sec).to_be_within_n_of {value=EPOCH, delta=1}
      expect(type(tv.tv_usec)).to_be "number"
      expect(tv.tv_usec >= 0).to_be(true)