THRIFT-4386 Add Lua 5.3/5.4 support
Clint: lua
Patch: Thomas Bruggink
This closes #3012
diff --git a/test/lua/Makefile.am b/test/lua/Makefile.am
index 00bdf3d..7cdbe04 100644
--- a/test/lua/Makefile.am
+++ b/test/lua/Makefile.am
@@ -19,11 +19,8 @@
THRIFT = $(top_builddir)/compiler/cpp/thrift
-# Remove "MapType =" line to ignore some map bug for now
-stubs: ../v0.16/ThriftTest.thrift $(THRIFT)
- $(THRIFT) --gen lua $<
- $(SED) -i.bak 's/MapType =//g' gen-lua/ThriftTest_ttypes.lua
- $(RM) gen-lua/ThriftTest_ttypes.lua.bak
+stubs: ../ThriftTest.thrift
+ $(THRIFT) --gen lua ../ThriftTest.thrift
precross: stubs
diff --git a/test/lua/test_basic_client.lua b/test/lua/test_basic_client.lua
index 11567d9..1932dd8 100644
--- a/test/lua/test_basic_client.lua
+++ b/test/lua/test_basic_client.lua
@@ -24,7 +24,7 @@
require('TJsonProtocol')
require('TBinaryProtocol')
require('ThriftTest_ThriftTest')
-require('liblualongnumber')
+local liblualongnumber = require('liblualongnumber')
local client
@@ -98,6 +98,9 @@
assertEqual(client:testString('lala'), 'lala', 'Failed testString')
assertEqual(client:testString('wahoo'), 'wahoo', 'Failed testString')
+ -- UUID
+ assertEqual(client:testUuid(TUUIDfromString('00112233-4455-6677-8899-aabbccddeeff')):getString(), '00112233-4455-6677-8899-aabbccddeeff', 'Failed testUuid')
+
-- Bool
assertEqual(client:testBool(true), true, 'Failed testBool true')
assertEqual(client:testBool(false), false, 'Failed testBool false')
diff --git a/test/lua/test_basic_server.lua b/test/lua/test_basic_server.lua
index 20ac407..0b421d1 100644
--- a/test/lua/test_basic_server.lua
+++ b/test/lua/test_basic_server.lua
@@ -24,7 +24,7 @@
require('TJsonProtocol')
require('TBinaryProtocol')
require('TServer')
-require('liblualongnumber')
+local liblualongnumber = require('liblualongnumber')
--------------------------------------------------------------------------------
-- Handler
@@ -62,10 +62,113 @@
return by
end
+function TestHandler:testUuid(uuid)
+ return uuid
+end
+
+function TestHandler:testNest(thing)
+ return thing
+end
+
function TestHandler:testStruct(thing)
return thing
end
+function TestHandler:testMap(thing)
+ return thing
+end
+
+function TestHandler:testStringMap(thing)
+ return thing
+end
+
+function TestHandler:testSet(thing)
+ return thing
+end
+
+function TestHandler:testList(thing)
+ return thing
+end
+
+function TestHandler:testEnum(thing)
+ return thing
+end
+
+function TestHandler:testTypedef(thing)
+ return thing
+end
+
+function TestHandler:testMapMap(hello)
+ return {
+ ["-4"] = {
+ ["-4"] = -4,
+ ["-3"] = -3,
+ ["-2"] = -2,
+ ["-1"] = -1
+ },
+ ["4"] = {
+ ["1"] = 1,
+ ["2"] = 2,
+ ["3"] = 3,
+ ["4"] = 4
+ }
+ }
+end
+
+function TestHandler:testInsanity(argument)
+ local first_map = {
+ [Numberz.TWO] = argument,
+ [Numberz.THREE] = argument
+ };
+ local second_map = {
+ [Numberz.SIX] = Insanity:new {
+ userMap = {},
+ xtructs = {}
+ }
+ }
+
+ return {
+ ["1"] = first_map,
+ ["2"] = second_map
+ };
+end
+
+function TestHandler:testMulti(arg0, arg1, arg2, arg3, arg4, arg5)
+ return Xtruct:new {}
+end
+
+function TestHandler:testException(arg)
+ if arg == "Xception" then
+ return Xception:new {
+ errorCode = 1001,
+ message = arg
+ }
+ elseif arg == "TException" then
+ error("")
+ end
+end
+
+function TestHandler:testMultiException(arg0, arg1)
+ if arg0 == "Xception" then
+ return Xception:new {
+ errorCode = 1001,
+ message = "This is an Xception"
+ }
+ elseif arg0 == "Xception2" then
+ return Xception2:new {
+ errorCode = 2002,
+ struct_thing = Xtruct:new {
+ string_thing = "This is an Xception2"
+ }
+ }
+ elseif arg0 == "TException" then
+ error("")
+ end
+ return Xtruct:new {
+ string_thing = arg1
+ }
+end
+
function TestHandler:testOneway(secondsToSleep)
print("testOneway secondsToSleep:", secondsToSleep)
end
diff --git a/test/tests.json b/test/tests.json
index 91aa767..015a559 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -695,24 +695,31 @@
},
"client": {
"timeout": 5,
- "transports": [
- "buffered",
- "framed",
- "http"
- ],
- "sockets": [
- "ip"
- ],
- "protocols": [
- "binary",
- "compact",
- "json"
- ],
"command": [
"lua",
"test_basic_client.lua"
]
},
+ "server": {
+ "delay": 5,
+ "command": [
+ "lua",
+ "test_basic_server.lua"
+ ]
+ },
+ "transports": [
+ "buffered",
+ "framed",
+ "http"
+ ],
+ "sockets": [
+ "ip"
+ ],
+ "protocols": [
+ "binary",
+ "compact",
+ "json"
+ ],
"workdir": "lua"
},
{