Blame specs/posix_sys_times_spec.yaml
|
Packit |
437b5e |
specify posix.sys.times:
|
|
Packit |
437b5e |
- before:
|
|
Packit |
437b5e |
tms = require "posix.sys.times"
|
|
Packit |
437b5e |
|
|
Packit |
437b5e |
- describe times:
|
|
Packit |
437b5e |
- before:
|
|
Packit |
437b5e |
table.unpack = table.unpack or unpack
|
|
Packit |
437b5e |
times = tms.times
|
|
Packit |
437b5e |
|
|
Packit |
437b5e |
# posix.times takes an optional string or table as its first
|
|
Packit |
437b5e |
# argument, followed by zero or more strings only if the first
|
|
Packit |
437b5e |
# argument was a string; since we can't express that with
|
|
Packit |
437b5e |
# `badargs.diagnose` do it all manually again...
|
|
Packit |
437b5e |
- context with bad arguments:
|
|
Packit |
437b5e |
badargs.diagnose (times, "()")
|
|
Packit |
437b5e |
|
|
Packit |
437b5e |
- it returns a PosixTms:
|
|
Packit |
437b5e |
expect (prototype (times ())).to_be "PosixTms"
|
|
Packit |
437b5e |
- it fetches everything without an argument:
|
|
Packit |
437b5e |
keys = {
|
|
Packit |
437b5e |
"tms_utime", "tms_stime", "tms_cutime", "tms_cstime", "elapsed"
|
|
Packit |
437b5e |
}
|
|
Packit |
437b5e |
t = times ()
|
|
Packit |
437b5e |
expect (t).to_contain.a_permutation_of (keys)
|
|
Packit |
437b5e |
for _, key in ipairs (keys) do
|
|
Packit |
437b5e |
expect (type (t[key])).to_be "number"
|
|
Packit |
437b5e |
end
|