From b182b416169dc5286df737b7bf64dd6be1bb8eef Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 13 Sep 2023 19:40:22 -0300 Subject: Support getting io.popen results on file:close() on PUC-Rio Lua 5.1 (#53) --- tests/test.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') diff --git a/tests/test.lua b/tests/test.lua index 0640cae..443f6f7 100755 --- a/tests/test.lua +++ b/tests/test.lua @@ -625,11 +625,13 @@ do end)) if mode ~= "module" then local f = assert(io.open(self, "r")) + print("io.type()", io.type(f)) for a,b in f:lines(2, "*l") do print("file:lines()", a, b) break end f:close() + print("io.type()", io.type(f)) f = assert(io.open("data.txt", "r")) for n1,n2,rest in f:lines("*n", "n", "*a") do print("file:lines()", n1, n2, rest) @@ -650,6 +652,18 @@ do end)) end os.remove("data.txt") + print("io.popen()", pcall(function() + local f = assert(io.popen("echo 'hello' && exit 0", "r")) + print("io.popen()", f:read("*a")) + print("io.popen()", f:close()) + end)) + print("io.popen()", pcall(function() + local f = assert(io.popen("echo 'hello' && exit 5", "r")) + print("io.type()", io.type(f)) + print("io.popen()", f:read("*a")) + print("io.popen()", f:close()) + print("io.type()", io.type(f)) + end)) end ___'' -- cgit v1.2.3-55-g6feb