Skip to content

Commit 37cf34b

Browse files
committed
Add test case for socket:unget roundtrip
1 parent d09c9d6 commit 37cf34b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

regress/90-unget-textmode.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
_=[[
3+
. "${0%%/*}/regress.sh"
4+
exec runlua "$0" "$@"
5+
]]
6+
require"regress".export".*"
7+
8+
local function test_with_mode(str, mode)
9+
local c, s = socket.pair()
10+
check(s:xwrite(str, "bn"))
11+
local foo = c:xread(-99999, mode)
12+
check(c:unget(foo, mode))
13+
local bar = c:xread(-99999, mode)
14+
check(foo == bar, "unget + read does not round trip")
15+
end
16+
local function test(str)
17+
info("testing: %q", str)
18+
test_with_mode(str, "t")
19+
test_with_mode(str, "b")
20+
end
21+
22+
test'test'
23+
test'test\n'
24+
test'hi\r\nthere\nworld\r'
25+
test'\n\n'
26+
test'foo\r\r\n'
27+
28+
say("OK")

0 commit comments

Comments
 (0)