summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorThijs <thijs@thijsschreijer.nl>2024-05-20 12:39:33 +0200
committerThijs <thijs@thijsschreijer.nl>2024-05-20 14:27:40 +0200
commit06c186da3c9108c9d0378e25a18bc6f605d43644 (patch)
tree90a3c1a3b71e5a1690eecfdf4435c102c87d769c /spec
parentdcd5d62501e61e0f6901d4d4687ab56430a4b8a7 (diff)
downloadluasystem-06c186da3c9108c9d0378e25a18bc6f605d43644.zip
implement getconsoleflags tests
Diffstat (limited to 'spec')
-rw-r--r--spec/04-term_spec.lua32
1 files changed, 20 insertions, 12 deletions
diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua
index ee4145a..487a0ce 100644
--- a/spec/04-term_spec.lua
+++ b/spec/04-term_spec.lua
@@ -106,21 +106,29 @@ describe("Terminal:", function()
- pending("getconsoleflags()", function()
-
- pending("returns the consoleflags, if called without flags", function()
-print"1"
-package.loaded["system"] = nil
-package.loaded["system.core"] = nil
-print"2"
-local system = require "system"
-print"3"
-for k,v in pairs(system) do print(k,v) end
-for k,v in pairs(debug.getinfo(system.isatty)) do print(k,v) end
+ describe("getconsoleflags()", function()
+ win_it("returns the consoleflags #manual", function()
local flags, err = system.getconsoleflags(io.stdin)
assert.is_nil(err)
- assert.is_integer(flags)
+ assert.is_userdata(flags)
+ assert.equals("bitflags:", tostring(flags):sub(1,9))
+ end)
+
+
+ nix_it("returns the consoleflags, as value 0", function()
+ local flags, err = system.getconsoleflags(io.stdin)
+ assert.is_nil(err)
+ assert.is_userdata(flags)
+ assert.equals("bitflags:", tostring(flags):sub(1,9))
+ assert.equals(0, flags:value())
+ end)
+
+
+ it("returns an error if called with an invalid argument", function()
+ assert.has.error(function()
+ system.getconsoleflags("invalid")
+ end, "bad argument #1 to 'getconsoleflags' (FILE* expected, got string)")
end)
end)