aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spec/04-term_spec.lua40
1 files changed, 35 insertions, 5 deletions
diff --git a/spec/04-term_spec.lua b/spec/04-term_spec.lua
index 487a0ce..77d2ce3 100644
--- a/spec/04-term_spec.lua
+++ b/spec/04-term_spec.lua
@@ -109,15 +109,15 @@ describe("Terminal:", function()
109 describe("getconsoleflags()", function() 109 describe("getconsoleflags()", function()
110 110
111 win_it("returns the consoleflags #manual", function() 111 win_it("returns the consoleflags #manual", function()
112 local flags, err = system.getconsoleflags(io.stdin) 112 local flags, err = system.getconsoleflags(io.stdout)
113 assert.is_nil(err) 113 assert.is_nil(err)
114 assert.is_userdata(flags) 114 assert.is_userdata(flags)
115 assert.equals("bitflags:", tostring(flags):sub(1,9)) 115 assert.equals("bitflags:", tostring(flags):sub(1,9))
116 end) 116 end)
117 117
118 118
119 nix_it("returns the consoleflags, as value 0", function() 119 nix_it("returns the consoleflags, always value 0", function()
120 local flags, err = system.getconsoleflags(io.stdin) 120 local flags, err = system.getconsoleflags(io.stdout)
121 assert.is_nil(err) 121 assert.is_nil(err)
122 assert.is_userdata(flags) 122 assert.is_userdata(flags)
123 assert.equals("bitflags:", tostring(flags):sub(1,9)) 123 assert.equals("bitflags:", tostring(flags):sub(1,9))
@@ -135,9 +135,39 @@ describe("Terminal:", function()
135 135
136 136
137 137
138 pending("setconsoleflags()", function() 138 describe("setconsoleflags()", function()
139 139
140 pending("sets the consoleflags, if called with flags", function() 140 win_it("sets the consoleflags #manual", function()
141 local old_flags = assert(system.getconsoleflags(io.stdout))
142 finally(function()
143 system.setconsoleflags(io.stdout, old_flags)
144 end)
145
146 local new_flags
147 if old_flags:has_all_of(system.COF_VIRTUAL_TERMINAL_PROCESSING) then
148 new_flags = old_flags - system.COF_VIRTUAL_TERMINAL_PROCESSING
149 else
150 new_flags = old_flags + system.COF_VIRTUAL_TERMINAL_PROCESSING
151 end
152
153 local success, err = system.setconsoleflags(io.stdout, new_flags)
154 assert.is_nil(err)
155 assert.is_true(success)
156
157 local updated_flags = assert(system.getconsoleflags(io.stdout))
158 assert.equals(new_flags:value(), updated_flags:value())
159 end)
160
161
162 nix_it("sets the consoleflags, always succeeds", function()
163 assert(system.setconsoleflags(io.stdout, system.getconsoleflags(io.stdout)))
164 end)
165
166
167 it("returns an error if called with an invalid argument", function()
168 assert.has.error(function()
169 system.setconsoleflags("invalid")
170 end, "bad argument #1 to 'setconsoleflags' (FILE* expected, got string)")
141 end) 171 end)
142 172
143 end) 173 end)