s.voidProc() excMsg = "" try: print(s.sumInts(1, 2, 3)) except TypeError as e: excMsg = str(e) assert (excMsg == "sumInts() takes exactly 2 arguments (3 given)") assert (s.someFunc1(__builtins__) == 10) assert (s.someFunc2(__builtins__) == 10) assert (s.someFunc3() == os.getcwd()) assert (s.tupleDiff((5, 4), (2, 3)) == (3, 1)) assert (s.tupleDiff([5, 4], (2, 3)) == (3, 1) ) # Python lists should be convertible to nim tuples assert (s.testDefaultArgs("hello, ", "world") == s.testDefaultArgs("hello, ")) assert (s.testJsonArgument({"foo": 666, "bar": False, "baz": 42.0}) == "ok") assert (s.testLambda(lambda x: x + 5) == 8) assert (s.testLambda2(lambda x: x + 5) == 8) receivedString = "" def receiveString(x): global receivedString
s.voidProc() excMsg = "" try: print(s.sumInts(1, 2, 3)) except TypeError as e: excMsg = str(e) assert(excMsg == "sumInts() takes exactly 2 arguments (3 given)") assert(s.someFunc1(__builtins__) == 10) assert(s.someFunc2(__builtins__) == 10) assert(s.someFunc3() == os.getcwd()) assert(s.tupleDiff((5, 4), (2, 3)) == (3, 1)) assert(s.tupleDiff([5, 4], (2, 3)) == (3, 1)) # Python lists should be convertible to nim tuples assert(s.testDefaultArgs("hello, ", "world") == s.testDefaultArgs("hello, ")) assert(s.testJsonArgument({"foo": 666, "bar": False, "baz": 42.0}) == "ok") assert(s.testLambda(lambda x: x + 5) == 8) assert(s.testLambda2(lambda x: x + 5) == 8) receivedString = "" def receiveString(x): global receivedString receivedString = x s.testVoidLambda(receiveString) assert(receivedString == "hello")