|
61 | 61 | function _G.test_io.test()
|
62 | 62 | local code = "assert(io.write(require 'pb.io'.read()))"
|
63 | 63 | 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")) |
65 | 65 | eq(fh:read "*a", code)
|
66 | 66 | fh:close()
|
67 | 67 | assert(os.remove "t.lua")
|
@@ -672,7 +672,7 @@ function _G.test_oneof()
|
672 | 672 | check_msg("TestOneof", { value = 0 })
|
673 | 673 | check_msg("TestOneof", { name = "foo", value = 0 })
|
674 | 674 |
|
675 |
| - data = { name = "foo", value = 5 } |
| 675 | + local data = { name = "foo", value = 5 } |
676 | 676 | check_msg("TestOneof", data)
|
677 | 677 | eq(pb.field("TestOneof", "name"), "name")
|
678 | 678 | pb.clear("TestOneof", "name")
|
@@ -801,6 +801,11 @@ function _G.test_buffer()
|
801 | 801 | eq(#b, 6)
|
802 | 802 |
|
803 | 803 | 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 |
804 | 809 |
|
805 | 810 | b = buffer.new()
|
806 | 811 | fail("encode bytes fail", function() b:pack("#", 10) end)
|
@@ -1013,6 +1018,11 @@ function _G.test_load()
|
1013 | 1018 | assert(pb.type ".google.protobuf.FileDescriptorSet")
|
1014 | 1019 | end
|
1015 | 1020 |
|
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 | + |
1017 | 1027 | -- unixcc: run='rm *.gcda; lua test.lua; gcov pb.c'
|
1018 | 1028 | -- win32cc: run='del *.gcda & lua test.lua & gcov pb.c'
|
0 commit comments