before: this_module = 'posix.sys.statvfs' global_table = '_G' M = require(this_module) specify posix.sys.statvfs: - context when required: - it does not touch the global table: expect(show_apis {added_to=global_table, by=this_module}). to_equal {} - describe statvfs: - before: statvfs = M.statvfs - context with bad arguments: if statvfs then badargs.diagnose(statvfs, "(string)") end - it returns a PosixStatvfs: if statvfs then expect(prototype(statvfs("/"))).to_be "PosixStatvfs" end - it fetches statistics for a mounted file system: if statvfs then sv = statvfs "/" expect(type(sv)).to_be "table" for _, field in pairs {"f_bsize", "f_frsize", "f_blocks", "f_bfree", "f_bavail", "f_files", "f_ffree", "f_favail", "f_flag", "f_namemax"} do expect(type(sv[field])).to_be "number" expect(sv[field] >= 0).to_be(true) end end - it returns a non-negative value from fsid: | -- Merge this back into the previous example when #102 is fixed if statvfs then sv = statvfs "/" pending "issue #102" expect(sv[field] >= 0).to_be(true) end