1- --- @diagnostic disable : param-type-mismatch , discard-returns
2-
31local tty = require " tty"
42
53local function tempfile ()
@@ -44,14 +42,17 @@ describe("tty", function()
4442 local err = " bad argument #1 to 'isatty' (expected a non-negative integer file descriptor or Lua file handle)"
4543
4644 -- stylua: ignore start
47- assert .Error (function () tty .isatty (" 1" ) end , err )
48- assert .Error (function () tty .isatty (- 1 ) end , err )
49- assert .Error (function () tty .isatty (1.5 ) end , err )
50- assert .Error (function () tty .isatty ({}) end , err )
45+ --- @diagnostic disable-next-line : param-type-mismatch
46+ assert .Error (function () _ = tty .isatty (" 1" ) end , err )
47+ assert .Error (function () _ = tty .isatty (- 1 ) end , err )
48+ assert .Error (function () _ = tty .isatty (1.5 ) end , err )
49+ assert .Error (function () _ = tty .isatty ({}) end , err )
5150 -- stylua: ignore end
5251
52+ --- @diagnostic disable-next-line : undefined-field
5353 assert .Throw (function ()
54- tty .isatty (1000000 )
54+ _ = tty .isatty (1000000 )
55+ --- @diagnostic disable : param-type-mismatch , discard-returns
5556 end , " invalid file descriptor" )
5657 end )
5758
@@ -61,6 +62,8 @@ describe("tty", function()
6162 finally (function ()
6263 os.remove (name )
6364 end )
65+
66+ --- @diagnostic disable-next-line : undefined-field
6467 assert .Throw (function ()
6568 tty .isatty (file )
6669 end , " closed" )
@@ -77,6 +80,7 @@ describe("tty", function()
7780 assert .True (rows >= 1 )
7881 assert .True (cols >= 1 )
7982 else
83+ --- @diagnostic disable-next-line : undefined-field
8084 assert .Throw (function ()
8185 tty .size ()
8286 end , " failed to get terminal size" )
@@ -92,6 +96,7 @@ describe("tty", function()
9296 assert .True (terminal_rows >= 1 )
9397 assert .True (terminal_cols >= 1 )
9498 else
99+ --- @diagnostic disable-next-line : undefined-field
95100 assert .Throw (function ()
96101 tty .size (io.stderr )
97102 end , " failed to get terminal size" )
@@ -104,12 +109,15 @@ describe("tty", function()
104109 file :close ()
105110 os.remove (name )
106111 end )
112+
113+ --- @diagnostic disable-next-line : undefined-field
107114 assert .Throw (function ()
108115 tty .size (file )
109116 end , " failed to get terminal size" )
110117 end )
111118
112119 it (" should reject invalid numeric file descriptors" , function ()
120+ --- @diagnostic disable-next-line : undefined-field
113121 assert .Throw (function ()
114122 tty .size (1000000 )
115123 end , " invalid file descriptor" )
@@ -123,6 +131,8 @@ describe("tty", function()
123131 os.remove (closed_name )
124132 end
125133 end )
134+
135+ --- @diagnostic disable-next-line : undefined-field
126136 assert .Throw (function ()
127137 tty .size (closed )
128138 end , " closed" )
0 commit comments