From b4c31d5ada077136404067e92df82452e0b07187 Mon Sep 17 00:00:00 2001 From: coffeepots Date: Wed, 16 May 2018 23:16:20 +0100 Subject: [PATCH] add test for `return` statement within `on` macro --- tests/testrpcmacro.nim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testrpcmacro.nim b/tests/testrpcmacro.nim index d4d2665..232282b 100644 --- a/tests/testrpcmacro.nim +++ b/tests/testrpcmacro.nim @@ -29,6 +29,7 @@ let var s = newRpcServer("localhost") # RPC definitions + s.on("rpc.simplepath"): result = %1 @@ -57,6 +58,9 @@ s.on("rpc.returntypecomplex") do(i: int) -> Test2: result.x = [1, i, 3] result.y = "test" +s.on("rpc.testreturns") do() -> int: + return 1234 + # Tests suite "Server types": @@ -68,6 +72,7 @@ suite "Server types": check s.procs.hasKey("rpc.objparam") check s.procs.hasKey("rpc.returntypesimple") check s.procs.hasKey("rpc.returntypecomplex") + check s.procs.hasKey("rpc.testreturns") test "Simple paths": let r = waitFor rpcSimplePath(%[]) @@ -107,6 +112,10 @@ suite "Server types": r1 = waitfor rpcReturnTypeComplex(%[%inp]) check r1 == %*{"x": %[1, inp, 3], "y": "test"} + test "Return statement": + let r = waitFor rpcTestReturns(%[]) + check r == %1234 + test "Runtime errors": expect ValueError: # root param not array