Skip to content

Commit 53d9ac1

Browse files
committed
improve coverage
1 parent 55c411b commit 53d9ac1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test.lua

+13-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ end
6161
function _G.test_io.test()
6262
local code = "assert(io.write(require 'pb.io'.read()))"
6363
assert(pbio.dump("t.lua", code))
64-
local fh = assert(io.popen("lua t.lua < t.lua", "r"))
64+
local fh = assert(io.popen(arg[-1].." t.lua < t.lua", "r"))
6565
eq(fh:read "*a", code)
6666
fh:close()
6767
assert(os.remove "t.lua")
@@ -672,7 +672,7 @@ function _G.test_oneof()
672672
check_msg("TestOneof", { value = 0 })
673673
check_msg("TestOneof", { name = "foo", value = 0 })
674674

675-
data = { name = "foo", value = 5 }
675+
local data = { name = "foo", value = 5 }
676676
check_msg("TestOneof", data)
677677
eq(pb.field("TestOneof", "name"), "name")
678678
pb.clear("TestOneof", "name")
@@ -801,6 +801,11 @@ function _G.test_buffer()
801801
eq(#b, 6)
802802

803803
fail("integer format error: 'foo'", function() pb.pack("v", "foo") end)
804+
if _VERSION == "Lua 5.3" then
805+
fail("integer format error", function() pb.pack("v", 1e308) end)
806+
else
807+
fail("number has no integer representation", function() pb.pack("v", 1e308) end)
808+
end
804809

805810
b = buffer.new()
806811
fail("encode bytes fail", function() b:pack("#", 10) end)
@@ -1013,6 +1018,11 @@ function _G.test_load()
10131018
assert(pb.type ".google.protobuf.FileDescriptorSet")
10141019
end
10151020

1016-
os.exit(lu.LuaUnit.run(), true)
1021+
if _VERSION == "Lua 5.1" and not _G.jit then
1022+
lu.LuaUnit.run()
1023+
else
1024+
os.exit(lu.LuaUnit.run(), true)
1025+
end
1026+
10171027
-- unixcc: run='rm *.gcda; lua test.lua; gcov pb.c'
10181028
-- win32cc: run='del *.gcda & lua test.lua & gcov pb.c'

0 commit comments

Comments
 (0)